How can I launch the iOS Simulator from Terminal?
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.
How to launch iOS Simulator in specific language from command line?
The only way to launch iOS Simulator
with specific language is to change contents of its .GlobalPreferences.plist
file. Using xcrun
tool will not work because it passess arguments to launched app and not changing language of simulator itself. Manipulation on .GlobalPreferences.plist
is quite difficult because it is a binary plist
file, so you cannot modify it as 'normal' xml
. The easiest way to change its contents is to write simple Xcode Command Line Tool application
, Foundation SDK
has all tools needed to modify binary plists
.
How to install iOS simulators from command line
It can be done with xcode-install, with the following commands
gem install xcode-install
xcversion simulators --install='iOS 9.3'
How to run iPhone emulator WITHOUT starting Xcode?
The easiest way without fiddling with command line:
- launch Xcode once.
- run ios simulator
- drag the ios simulator icon to dock it.
Next time you want to use it, just click on the ios simulator icon in the dock.
How to launch specific iOS simulator?
Get a list of device names:
Run xcrun simctl list devices
, which would output:
== Devices ==
-- iOS 14.5 --
-- iOS 14.5 --
iPhone 8 (FA86F02A-B7AF-412B-996C-7B086025A73C) (Shutdown)
iPhone 8 Plus (F9FB94EA-3EFE-497E-A994-7C112CD65462) (Shutdown)
iPhone 11 (C14D6993-CA37-4E50-86C9-0D2827B35D48) (Shutdown)
iPhone 11 Pro (4E137620-962B-4756-B913-2EE9AF99D3D6) (Shutdown)
iPhone 11 Pro Max (935DA14A-A4AB-4EC0-8AFB-103ABF2C6608) (Shutdown)
iPhone SE (2nd generation) (1C78EEFC-293D-4EBD-8F4C-9FACEB842631) (Shutdown)
iPhone 12 mini (A4ED4EF6-8F84-452F-927D-40BA30D6CF62) (Booted)
iPhone 12 (92F57737-CB75-4A99-84BB-E221F156B578) (Booted)
iPhone 12 Pro (C62C81AB-18C7-4DAD-9023-AD4E1A64140F) (Shutdown)
iPhone 12 Pro Max (BF1967DF-A0A7-4740-961F-DCBEB4CAFF60) (Shutdown)
iPod touch (7th generation) (47DFA553-1955-49BA-A4D3-CE7C397282AC) (Shutdown)
iPad Pro (9.7-inch) (0E84438C-2369-4D26-ABBE-BC0B71E76839) (Shutdown)
iPad (8th generation) (C7ABF216-2256-4715-9FAB-F83EA595ECEB) (Shutdown)
iPad Air (4th generation) (E7B4E2E7-88F6-4133-ACE5-7B8B19E96F43) (Shutdown)
iPad Pro (11-inch) (3rd generation) (9793FE60-0749-49D8-8ACE-4B46C1B4901B) (Shutdown)
iPad Pro (12.9-inch) (5th generation) (8755F8FE-EDCB-4603-B0D0-262A83DC723A) (Shutdown)
-- tvOS 14.5 --
Apple TV (3FEF7ABC-4CED-4473-9B76-63C19707B28C) (Shutdown)
Apple TV 4K (2nd generation) (200C414D-4699-4F3A-8E28-0DC6D598E557) (Shutdown)
Apple TV 4K (at 1080p) (2nd generation) (7363F807-A22F-49B2-917A-F248002EABDB) (Shutdown)
-- watchOS 7.4 --
Apple Watch Series 5 - 40mm (71BD5079-1D90-421F-925C-4D9F288F7535) (Shutdown)
Apple Watch Series 5 - 44mm (3F587446-DC30-4C5D-A101-0D6D53B3E71F) (Shutdown)
Apple Watch Series 6 - 40mm (CAE878C0-9DD5-4E74-9BE9-2262819BA43D) (Shutdown)
Apple Watch Series 6 - 44mm (000CCEE8-E41B-4D52-B755-69B37D2BBC5E) (Shutdown)
-- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-15-0 --
iPad (9th generation) (B2819113-C651-47F8-9ABF-38FBB530927A) (Shutdown) (unavailable, runtime profile not found)
iPad mini (6th generation) (B2D49664-1582-4A37-918B-53EA0ADAA898) (Shutdown) (unavailable, runtime profile not found)
iPhone 13 (43F7E023-6AEF-4ED0-8FCC-E88303DE3B70) (Shutdown) (unavailable, runtime profile not found)
iPhone 13 Pro (1C2C397B-9774-459A-B4F1-81CDE52D0246) (Shutdown) (unavailable, runtime profile not found)
iPhone 13 Pro Max (0BCB5E9B-A527-46FA-B952-9F3629AF84D5) (Shutdown) (unavailable, runtime profile not found)
iPhone 13 mini (00CBE649-0FD7-49EF-AE95-53DAAE3DDCBE) (Shutdown) (unavailable, runtime profile not found)
-- Unavailable: com.apple.CoreSimulator.SimRuntime.watchOS-8-0 --
Apple Watch Series 7 - 41mm (DAC19B17-E885-4B21-B1B3-85969EE0E693) (Shutdown) (unavailable, runtime profile not found)
Apple Watch Series 7 - 45mm (F73EAA78-5B3E-4E9D-8643-1EFC1CF1F990) (Shutdown) (unavailable, runtime profile not found)
Then, launch by device name:
xcrun simctl boot "iPhone 12"
Note: In CI/CD, you could use a device variable or matrix to run on multiple devices instead, e.g. xcrun simctl boot "${{ matrix.device }}"
.
To launch your app
Run xcrun simctl launch "iPhone 12" com.example.app-name
. You can check the device is booted, by running xcrun simctl list devices | grep "iPhone 12"
.
To see the UI
Just open the Simulator.app
Can I start the iPhone simulator without Build and Run ?
The simulator is just an application, and as such you can run it like any other application.
To open it in Spotlight, search for Simulator
.
To run the simulator straight from terminal, prepend these locations with the open
command.
Xcode 7.x, 8.x, 9.x, 10.x, 11.x, 12.x, and 13.x
In Xcode 7.x - 13.x, the iPhone Simulator has moved again: /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
.
Xcode 6.x
In Xcode 6.x, the iPhone Simulator has moved yet again, and now resides here: /Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app
.
Xcode 4.x, 5.x
In Xcode 4.x (through 4.5 on Mountain Lion) and Xcode 5.0.x on Mavericks, it lives here: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/
In my version of Xcode (4.5.2), I find it quite convenient to use the Open Developer Tool
menu from either the dock icon or the Xcode menu:
Xcode 3.x
In Xcode 3.x, it lives here:
/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app
In some future version of Xcode, it will probably move again, it's a squirrelly little app.
Related Topics
What Are the Device-Width CSS Viewport Sizes of the Iphone6 and iPhone 6 Plus
Fix CSS Hover on Iphone/Ipad/Ipod
App Killed by Sigkill When Changing Privacy Settings
Uitableview Checkmark Only One Row at a Time
Issue with Code Autocompletion/Syntax Highlighting in Xcode 4.X
How to Detect When Avplayer Video Ends Playing
Launch Apple Mail App from Within My Own App
iOS 8 - Buttons in Horizontal Scroll View Intercepting Pan Event - Scroll Does Not Work
Can't Assign Multiple Buttons to Uinavigationitem When Using Storyboard with iOS 5
Implementing Hmac and Sha1 Encryption in Swift
Nsfetchedresultscontroller V.S. Uilocalizedindexedcollation
Change the Width of Master in Uisplitviewcontroller
Differences Between Udid and Uuid
How to Stop Multiple Times Method Calling of Didupdatelocations() in iOS
Making a Button Persistent Across All View Controllers
How to Set an Nsdate Object to Midnight
Cannot Put a Google Maps Gmsmapview in a Subview of Main Main View