How can I launch the iOS Simulator from Terminal?

IosXcodeTerminal

Ios Problem Overview


I can build using the Xcode command line tools, is there any way I can actually run the application using them? (E.g. the equivalent to pressing Cmd+R in Xcode)

Ios Solutions


Solution 1 - Ios

Type this in terminal: open -a Simulator.app

Solution 2 - Ios

First decide what device you want to use:

xcrun simctl list

This will give you a list of devices:

-- iOS 9.0 --
    iPhone 4s (56632E02-650E-4C24-AAF4-5557FB1B8EB2) (Shutdown)
    iPhone 5 (ACD4DB7B-9FC9-49D5-B06B-BA5D5E2F5165) (Shutdown)
    iPhone 5s (A8358B76-AD67-4571-9EB7-FFF4D0AC029E) (Shutdown)
    iPhone 6 (1D46E980-C127-4814-A1E2-5BE47F6A15ED) (Shutdown)
    iPhone 6 Plus (FD9F726E-453A-4A4C-9460-A6C332AB140B) (Shutdown)

Choose the ID (eg. FD9F726E-453A-4A4C-9460-A6C332AB140B) you want (you can create your own device using xcrun simctl create if you want).

Boot the simulator with that device (replacing YOUR-DEVICE-ID with the ID)

/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID <YOUR-DEVICE-ID>

Now you should be able to use simctl to install and launch commands.

xcrun simctl install <YOUR-DEVICE-ID> <PATH-TO-APPLICATION-BUNDLE>
xcrun simctl launch <YOUR-DEVICE-ID> <BUNDLE-ID-OF-APP-BUNDLE>

xcrun simctl help for more details. Note that booting a device using simctl does not currently (Xcode 7.2) allow you to do anything else with that device such as launch or install applications. You need to launch the device in the simulator to actually do anything interesting. Also, you cannot delete a device that is in use by the simulator, so you will have to quit/kill the simulator before attempting to delete anything.

Solution 3 - Ios

open -a simulator 

it worked for me

Solution 4 - Ios

As of this date (2022) it will work:

open -a simulator 

it is the easiest way.

Solution 5 - Ios

Open your terminal and paste this code:

open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app

iOS Simulator Folder Path

Solution 6 - Ios

This is the answer you are looking for:

  1. Open terminal

  2. xcrun simctl list

  3. Get udid of the device you want to launch

  4. Paste this in the terminal

  5. open -a Simulator --args -CurrentDeviceUDID 0566AC33-9B91-2DR2-B5BB-C916D3BA8MD3

Solution 7 - Ios

Use xcrun simctl list to get a list of simulators and their UDIDs. Then open a specific simulator using xcrun simctl boot <UDIDs>

Solution 8 - Ios

open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app/

Solution 9 - Ios

# Update In the new Xcode update, supported simulators are from iPhone 8 onwards

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlex ChestersView Question on Stackoverflow
Solution 1 - IosMathioli RamalingamView Answer on Stackoverflow
Solution 2 - IosdmaclachView Answer on Stackoverflow
Solution 3 - IosBenjith KizhisseriView Answer on Stackoverflow
Solution 4 - IosAli AbbasView Answer on Stackoverflow
Solution 5 - IosJulian Alejandro SosaView Answer on Stackoverflow
Solution 6 - IosAdrian JimenezView Answer on Stackoverflow
Solution 7 - IosAuligView Answer on Stackoverflow
Solution 8 - IosLlogari CasasView Answer on Stackoverflow
Solution 9 - IosDionisio MaltesoView Answer on Stackoverflow