How can I launch the iOS Simulator from Terminal?
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
Alex Chesters
Updated on January 30, 2022Comments
-
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 almost 9 yearsThat 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 almost 9 yearsThe 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 almost 9 years@Llorgi you can build your code from the terminal without Xcode
-
Llogari Casas almost 9 yearsSure you can compile your code trough terminal. But you are still using
Xcode Command Line Tools
. Examplexcodebuild test -scheme MyiOSApp -destination 'platform=iOS,name=iPod touch'
@AlexChesters -
Palleraccio over 7 yearsA little tip.. once the device is booted, you can use the keyword
booted
instead of<YOUR-DEVICE-ID>
. -
Mark Pieszak - Trilon.io almost 6 yearsThis is the simplest way to do it. :+1:
-
kosiara - Bartosz Kosarzycki over 5 yearsYou can find compiled application bundle in:
/Users/username/Library/Developer/Xcode/DerivedData/YourApp-cuozdynseabctdefrjsejhldxden/Build/Products/Debug-iphonesimulator
-
MAhipal Singh over 5 years@Kuldeep Can you explain why this answer is not appropriate to the question?
-
MAhipal Singh over 5 years@Benjith Kizhisseri , this answer was already posted here: stackoverflow.com/a/49992522/6898523 please avoid duplicate answers.
-
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 over 5 yearsI 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 over 5 yearsSimple and fast :)
-
code-8 about 5 years@kosiara-BartoszKosarzycki Is there a command line to show that path ?
-
dmaclach about 5 yearsIt 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 almost 5 years
open -a Simulator --args -CurrentDeviceUDID <YOUR-DEVICE-ID>
also works for starting the simulator -
MNFS over 4 yearsWhat is<PATH-TO-APPLICATION-BUNDLE> and <BUNDLE-ID-OF-APP-BUNDLE> ?
-
dmaclach over 4 yearsAn example of path-to-application-bundle is
/MyDrive/MyFolder/MyApp.app
An example of bundle-id-of-app-bundle iscom.mycompany.myapp
-
Antonio Carlos almost 4 yearsWhen 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 usexcrun simctl boot <YOUR-DEVICE-ID>
to boot another device. -
Dami over 3 yearsIt 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 withNew Simulator
) -
Alann Maulana about 3 yearssimply run directly into a selected device
-
Alejandro Giraldo about 3 yearsPretty simple solution
-
Thiago about 3 yearsThe easiest way is - (open -a Simulator.app)
-
ICW almost 3 years@MAhipalSingh
"simulator" != "Simulator.app" // true
-
friederbluemle over 2 yearsIt 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 over 2 yearslist 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/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-18132/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/Foundation/Specifications/XCSpecification.m:1504 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 over 2 yearsMy 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/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-18132/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/Foundation/Specifications/XCSpecification.m:1504 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 about 2 yearsUnable to find application named 'MyApp.app'
-
Rohit Singh about 2 yearsI simply dragged and dropped in my simulator and it installed the app for me.
-
William Humphries almost 2 yearswhat do you have to download to use the command?