How can I launch the iOS Simulator from Terminal?

102,386

Solution 1

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 2

Type this in terminal: open -a Simulator.app

Solution 3

open -a simulator 

it worked for me

Solution 4

As of this date (2022) it will work:

open -a simulator 

it is the easiest way.

Solution 5

Open your terminal and paste this code:

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

iOS Simulator Folder Path

Share:
102,386
Alex Chesters
Author by

Alex Chesters

Updated on January 30, 2022

Comments

  • Alex Chesters
    Alex Chesters over 2 years

    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)

  • Alex Chesters
    Alex Chesters almost 9 years
    That will just launch the Simulator, I'm looking for a way to do the same as Cmd+R in the terminal, launching the Simulator AND running the app
  • Llogari Casas
    Llogari Casas almost 9 years
    The app must be installed trough Xcode to the simulator. Once you have done that at least once, you app will be saved on the simulator and accesible either from Xcode or Terminal. You can not compile by any means your code without Xcode @AlexChesters
  • Alex Chesters
    Alex Chesters almost 9 years
    @Llorgi you can build your code from the terminal without Xcode
  • Llogari Casas
    Llogari Casas almost 9 years
    Sure you can compile your code trough terminal. But you are still using Xcode Command Line Tools. Example xcodebuild test -scheme MyiOSApp -destination 'platform=iOS,name=iPod touch' @AlexChesters
  • Palleraccio
    Palleraccio over 7 years
    A little tip.. once the device is booted, you can use the keyword booted instead of <YOUR-DEVICE-ID>.
  • Mark Pieszak - Trilon.io
    Mark Pieszak - Trilon.io almost 6 years
    This is the simplest way to do it. :+1:
  • kosiara - Bartosz Kosarzycki
    kosiara - Bartosz Kosarzycki over 5 years
    You can find compiled application bundle in: /Users/username/Library/Developer/Xcode/DerivedData/YourApp-‌​cuozdynseabctdefrjse‌​jhldxden/Build/Produ‌​cts/Debug-iphonesimu‌​lator
  • MAhipal Singh
    MAhipal Singh over 5 years
    @Kuldeep Can you explain why this answer is not appropriate to the question?
  • MAhipal Singh
    MAhipal Singh over 5 years
    @Benjith Kizhisseri , this answer was already posted here: stackoverflow.com/a/49992522/6898523 please avoid duplicate answers.
  • Kuldeep
    Kuldeep over 5 years
    @MAhipalSingh, I didn't see any not appropriate word in comment and As a reviewer there's predefine options where you only able to select from them.
  • yshahak
    yshahak over 5 years
    I can't see why this "does not provide an answer to the question". This is the shortest answer to the question in this page and therefore this is a useful answer.
  • C-lio Garcia
    C-lio Garcia over 5 years
    Simple and fast :)
  • code-8
    code-8 about 5 years
    @kosiara-BartoszKosarzycki Is there a command line to show that path ?
  • dmaclach
    dmaclach about 5 years
    It doesn't answer the question because it doesn't run the application. The poster wanted something that would run an app for them, not just launch the simulator.
  • sgdesmet
    sgdesmet almost 5 years
    open -a Simulator --args -CurrentDeviceUDID <YOUR-DEVICE-ID> also works for starting the simulator
  • MNFS
    MNFS over 4 years
    What is<PATH-TO-APPLICATION-BUNDLE> and <BUNDLE-ID-OF-APP-BUNDLE> ?
  • dmaclach
    dmaclach over 4 years
    An example of path-to-application-bundle is /MyDrive/MyFolder/MyApp.app An example of bundle-id-of-app-bundle is com.mycompany.myapp
  • Antonio Carlos
    Antonio Carlos almost 4 years
    When using only open -a Simulator --args -CurrentDeviceUDID <YOUR-DEVICE-ID> though I replaced the device id it was launching the same device. In the end, I had to use xcrun simctl boot <YOUR-DEVICE-ID> to boot another device.
  • Dami
    Dami over 3 years
    It still works. If you have to open a specific simulator try the open -a simulator command. Let it open whatever the simulator it is going to open by default. Then with top bar menu, select, File > Open Simulator. ( or you create new one with New Simulator )
  • Alann Maulana
    Alann Maulana about 3 years
    simply run directly into a selected device
  • Alejandro Giraldo
    Alejandro Giraldo about 3 years
    Pretty simple solution
  • Thiago
    Thiago about 3 years
    The easiest way is - (open -a Simulator.app)
  • ICW
    ICW almost 3 years
    @MAhipalSingh "simulator" != "Simulator.app" // true
  • friederbluemle
    friederbluemle over 2 years
    It should be noted that this does boot the simulator, but does not actually open the UI. For that, you still need open -a Simulator.
  • sejn
    sejn over 2 years
    list command shows the error xcrun simctl list 2021-12-06 18:20:20.358 xcodebuild[12224:520286] [MT] DVTAssertions: ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEXcode3ProjectSuppor‌​t/IDEXcode3ProjectSu‌​pport-18132/Xcode3Co‌​re/LegacyProjects/Fr‌​ameworks/DevToolsCor‌​e/DevToolsCore/Found‌​ation/Specifications‌​/XCSpecification.m:1‌​504 Details: propertyList should be an instance inheriting from TSPropertyListDictionary, but it is nil Object: <XCSpecificationProxy: 0x7fca68666110> Method: -loadedSpecification Thread: <NSThread: 0x7fca667098d0>{number = 1, name = main} Hints:
  • sejn
    sejn over 2 years
    My list displays the error xcrun simctl list 2021-12-06 18:20:20.358 xcodebuild[12224:520286] [MT] DVTAssertions: ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEXcode3ProjectSuppor‌​t/IDEXcode3ProjectSu‌​pport-18132/Xcode3Co‌​re/LegacyProjects/Fr‌​ameworks/DevToolsCor‌​e/DevToolsCore/Found‌​ation/Specifications‌​/XCSpecification.m:1‌​504 Details: propertyList should be an instance inheriting from TSPropertyListDictionary, but it is nil Object: <XCSpecificationProxy: 0x7fca68666110> Method: -loadedSpecification Thread: <NSThread: 0x7fca667098d0>{number = 1, name = main} Hints:
  • Rohit Singh
    Rohit Singh about 2 years
    Unable to find application named 'MyApp.app'
  • Rohit Singh
    Rohit Singh about 2 years
    I simply dragged and dropped in my simulator and it installed the app for me.
  • William Humphries
    William Humphries almost 2 years
    what do you have to download to use the command?