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/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication MyApp.app/MyApp
but this opens a new finder window named "iOS Simulator could not find the application to simulate".
I made a shell script which installs the app to the simulator.
#!/bin/sh
# Pick a uuid for the app (or reuse existing one).
if ! [ -f installApp.uuid ]; then
uuidgen > installApp.uuid
fi
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/$1.app"
#copy all the app file to the simulators directory
cp -r * "$TOPDIR/$1.app"
How to use this script to install the app:
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
.
Save the script as installApp.sh
in your project_name.app/
folder.
Open a terminal window and run installApp
from the project directory.
project_name.app/
with a project inside. Type in the terminal:
cd path/to/project_name.app/
./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:
First you need to find the app directory (assuming you have installed apps): find ~/Library/Developer/CoreSimulator/Devices -name '*.app'
This will list all the paths that have a custom app installed. E.g.
/34792D41-55A9-40F5-AAC5-16F742F1F3E4/data/Containers/Bundle/Application/4BA2A285-6902-45A8-9445-FC3E46601F51/YourApp.app
device.plist
file. This file will contain the device it is simulating:<dict> ... <string>34792D41-55A9-40F5-AAC5-16F742F1F3E4</string> <string>com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus</string> ... </dict>
TOPDIR
path to $HOME/Library/Developer/CoreSimulator/Devices/{UUID for device}/data/Containers/Bundle/Applications/$UUID/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With