stackErr stackErr - 10 months ago 77
Bash Question

Script to install app in iOS Simulator

I am trying to automate the process of building an app, running unit tests, and finally running UI tests.

I am building the app via command line (xcodebuild -sdk iphonesimulator6.0) in some directory.

How do I install this app to the iOS simulator via command line (in ~/Library/Application Support/iPhone Simulator//Applications)?

I tried:

/Applications/\\ Simulator -SimulateApplication

but this opens a new finder window named "iOS Simulator could not find the application to simulate".

Answer Source

I made a shell script which installs the app to the simulator.

# Pick a uuid for the app (or reuse existing one).
if ! [ -f installApp.uuid ]; then
    uuidgen > installApp.uuid
UUID=$(cat installApp.uuid)
#create supporting folders
TOPDIR="$HOME/Library/Application Support/\
iPhone Simulator/6.0/Applications/$UUID/"
mkdir -p "$TOPDIR"
mkdir -p "$TOPDIR/Documents"
mkdir -p "$TOPDIR/Library"
mkdir -p "$TOPDIR/tmp"
mkdir -p "$TOPDIR/$"

#copy all the app file to the simulators directory
cp -r * "$TOPDIR/$"

How to use this script to install the app:

  1. Change this line:

    TOPDIR="$HOME/Library/Application Support/iPhone Simulator/6.0/Applications/$UUID/"

    to reflect the version of iPhone Simulator you are using i.e. 6.0/7.1.

  2. Save the script as in your folder.

  3. Open a terminal window and run installApp from the project directory.

    • So if I have my with a project inside. Type in the terminal:

      cd path/to/

    • Then ./installApp to install the app to the simulator.

I got the idea from Jeffrey Scofield: Run iOS Simulator from the Command Line

For iOS8 and the new XCode Apple changed a few things and made it difficult to install apps via the command line. It is still possible to do:

  1. First you need to find the app directory (assuming you have installed apps): find ~/Library/Developer/CoreSimulator/Devices -name '*.app'

  2. This will list all the paths that have a custom app installed. E.g.


  1. There will be multiple UUID parent directories with the structure above. Each UUID corresponds to a simulator for a different device. Open the top directory and you will find a device.plist file. This file will contain the device it is simulating:
  1. If you want to install your app for iPhone-6-Plus this is the directory you would do it in. Run the shell script above to install the app. Change the TOPDIR path to $HOME/Library/Developer/CoreSimulator/Devices/{UUID for device}/data/Containers/Bundle/Applications/$UUID/