Run iPhone/iPad Simulator for Continuous Integration

17,698

Solution 1

Use the -SimulateApplication argument to run your executable in the simulator (executable inside the .app bundle)

(you could also compile the project from the command-line like this:) xcodebuild -project Test.xcodeproj -arch i386 -sdk iphonesimulator

Then for example:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication Test.app/Test

or

./Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication Test.app/Test

Solution 2

To launch a specific device you can do:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateDevice "iPhone Retina (3.5-inch)"

Solution 3

Try this in your shell for Xcode 6

osascript -e 'activate application "iOS Simulator"'

For Xcode 7

osascript -e 'activate application "Simulator"'

Solution 4

If you want to open Simulator with specific app installed then you can use some of the ready utility to launch simulator. This way it is easy to install the app and run on the simulator. This are the command line utilities that can be run from Terminal Window.

  1. iPhoneSim
  2. ios-sim
  3. Other are same as above two.

And main thing is all uses same approach to open simulator. (see the project for more details)

Other way (not recommended by me) use script file to run from command.

Share:
17,698
rynmrtn
Author by

rynmrtn

Updated on June 10, 2022

Comments

  • rynmrtn
    rynmrtn almost 2 years

    I am attempting to run the iOS simulator from the command line. I have found the location where the iPhone Simulator can be run from. My question is whether or not it can receive parameters to specify which device should be launched and what app it should run.

    $ ./Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone\ Simulator

    Does anyone know if there are tricks to this. Knowing more about this would really help with our Continuous Integration process.


    We now use WaxSim to automate our iOS applications during CI Builds

  • elimirks
    elimirks over 11 years
    Although, I am getting an error that makes it seem like I need to set the sdk or something...
  • Chris McGrath
    Chris McGrath over 11 years
    elimirls: You may have tried to get the simulator to run MyApp.app, rather than MyApp.app/MyApp.
  • Roger Binns
    Roger Binns over 11 years
    Your second link (ios-sim) is now dead. Also not mentioned is what happens with NSLog/console output. For example invoking the simulator directly does not show it.
  • jab
    jab over 10 years
    This doesn't seem to work with Xcode 5 on Mavericks.