Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6 - Launch simulator from command line

I want to launch iPhone simulator from command line.

until now I have been using the below command

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator -SimulateDevice

-SimulateDevice is used to launch a specific device type

Now with Xcode 6 the path and the app has been changed to

/Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app/Contents/MacOS/iOS Simulator

but sadly -SimulateDevice option is not working now. I can launch the simulator, but dont have an option to specify which one to launch

Anyone found any alternatives for this with Xcode 6?

like image 675
Balaji Sekar Avatar asked Sep 25 '14 05:09

Balaji Sekar


People also ask

How do I start Xcode simulator from terminal?

In this article, I collected several options on how to launch the simulator from the Terminal, folder, search, and Xcode. Choose which option you like more and use. The basic way to open a list of simulators is to use Xcode -> Window -> Devices and Simulators. Here you can create and manage all available simulators.

How do I open the simulator from the command-line?

Starting the emulator Use the emulator command to start the emulator, as an alternative to running your project or starting it through the AVD Manager. Here's the basic command-line syntax for starting a virtual device from a terminal prompt: emulator -avd avd_name [ {- option [ value ]} … ]

How do I launch Xcode simulator?

Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download. When a simulator is opened from AppStudio, AppStudio Player automatically installs (if necessary) and opens in it.

What is Xcrun command?

xcrun provides a means to locate or invoke coexistence- and platform-aware developer tools from the command-line, without requiring users to modify makefiles or otherwise take inconvenient measures to support multiple Xcode toolchains.


2 Answers

Found a way to achieve what I wanted.

Apple has introduced an interesting tool with Xcode 6!

simctl

simclt allows you to control the simulator that are running.

run xcrun simctl to get the list of available subcommands. Lots of new options to play around with.

Now to do what I wanted, here is the command to launch the simulator:

xcrun instruments -w "iPhone 5 (8.0 Simulator)"

-w is to provide a device type and to get the list of available devices.

Just execute this:

xcrun instruments -s

After launching the simulator you can control it using simctl

To install your app:

xcrun simctl install booted <app path>

To launch the app:

xcrun simctl launch booted <app identifier>

Hope this helps.

like image 100
Balaji Sekar Avatar answered Oct 18 '22 06:10

Balaji Sekar


With Xcode 6, if you want to have the iOS Simulator.app boot a specific device when it launches, you can run this from the command line:

open -a "iOS Simulator" --args -CurrentDeviceUDID <DEVICE UDID>

where you can figure out the UDID of the device you want to boot from:

xcrun simctl list

With Xcode 7, the application was renamed Simulator.app, so you should update the above accordingly to:

open -a Simulator --args -CurrentDeviceUDID <DEVICE UDID>

like image 29
Jeremy Huddleston Sequoia Avatar answered Oct 18 '22 08:10

Jeremy Huddleston Sequoia