iOS Simulators — Tricks & Tips
--
Viewing/Adding A Simulator
You can change or add simulators by going to Product > Destination. To add, select Add Additional Simulators.
You can also access the list of simulators from the top toolbar by selecting the currently selected simulator:
From the Add Simulator options, you can select the “+” in the bottom left corner to create a new simulator as shown below:
To View the list of simulators from command line, run the following command:
xcrun simctl list
To add a new simulator from command line, run the following:
xcrun simctl create <simulator name> <sim device type> <sim runtime>Example:
xcrun simctl iPhoneSEGen2 com.apple.CoreSimulator.SimDeviceType.iPhone-SE--2nd-generation- com.apple.CoreSimulator.SimRuntime.iOS-15-2
Clearing the Simulator
Sometimes you want to clear the simulator to put it back in the starting state. You can do this by selecting the simulator and then going to the Device menu and selecting Erase All Contents and Settings.
From the command line, you can also kill all simulators by running the following commands. The last two can be used if you are using simulator clones (for parallel testing).
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
xcrun simctl --set testing shutdown all
xcrun simctl --set testing erase all
Simulator Clones
If you want to use simulator clones for parallel testing, go to Product > Scheme > Edit Scheme. Select Test. If you don’t have Test Plans enabled for the scheme, then you can select Options > Execute in Parallel. If you do have Test Plans enabled, select the Test Plan > button and change parallelizable to be true.
If you want to run tests via command line in parallel and specify the number of simulators to use, you can use certain parameters for the xcodebuild command:
xcodebuild ...-parallel-testing-enabled YES
-parallel-testing-worker-count 2...
If you aren’t seeing the simulator clones, make sure this option is checked:
Simulator Keyboard
When you select on a text field in the simulator manually or during a test, the keyboard may — or may not — appear. If its not doing what you need try toggling these keyboard settings:
Simulator — Stop Hiding!
If you want to make sure you can always view watch/view your simulator, then select the Stay On Top option from the Window menu: