iOS Simulator & xcrun simctl - Part 2
The iOS Simulator has a wide range of settings, which can be changed via the menu. In a continuous integration system it’s essential to be able to change these settings within an automated script. The simctl gem has some features that help you automating these setting changes in the iOS Simulator.
iOS Simulator settings
It is possible to change the window size of the Simulator.app:
This can also be achieved by passing some options to the
launch! method of the
In the Debug menu there are some settings that are written to some preferences
file in the plist format. The file can be found here:
This path might change in later versions of Xcode, the path displayed here is for version 7.3 of Xcode.
To see how these settings are named in the plist, just change something in the menu and see afterwards what has changed in the file. Most of these settings can be passed as launch arguments to the Simulator.app.
The simctl gem does support this too:
After launching the Simulator.app like this, the settings in the Debug menu have changed:
Other behaviour can be modified inside the Simulator via the iOS app called
Settings, just like on a real iPhone or iPad. These settings are not stored
com.apple.iphonesimulator.plist, instead they are stored in another file,
which is different for each device. The path to this file depends on the
of the device. There’s an easy way to find this path:
If you need to change some of these settings as part of your CI setup, the simctl gem can be helpful. First you need to figure out how these settings are called in the plist file. Just change them in the Simulator’s Settings app and see what has changed in the file. To disable all the keyboard related settings you would do:
Now the keyboard section in the Settings app looks like this:
These keyboard settings can interfere when you’re using some sort of UI Testing (e.g. KIF) that involves real typing on the keyboard. Autocorrection will not be your friend in that case. Because this might be a common scenario, the simctl gem has a shorter way to disable all these keyboard settings:
That’s all for today, let’s see if I can make it for another part.
You can read more about this topic in part 1.