How to Launch the iOS Simulator from Terminal

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 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

Opening specific simulator on Mac book

Rather than using Terminal you could do the following:

Open the Simulator app from Spotlight:

cmd + spacebar -> Search "Simulator" -> Enter

Then on the Simulator app do:

File -> Open Simulator -> Select iOS version -> Select device type.

Then pin the Simulator app to your dock by pressing and holding the Simulator app icon, hover over options and select Keep in Dock.

How to run iPhone emulator WITHOUT starting Xcode?

The easiest way without fiddling with command line:

  1. launch Xcode once.
  2. run ios simulator
  3. 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 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'

IOS simulator is not open

I am getting an error in Xcode 13.4 but when I download Xcode 13.2.1 issue is solved



Related Topics



Leave a reply



Submit