public
Last active

Run Xcode Simulator project from the command line

  • Download Gist
sim-run.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#!/bin/bash
#
# Build and iPhone Simulator Helper Script
# Shazron Abdullah 2011
#
# WARN: - if your .xcodeproj name is not the same as your .app name,
# this won't work without modifications
# - you must run this script in where your .xcodeproj file is
 
PROJECTNAME=$1
CONFIGURATION=$2
LOGFILE=$3
 
function help
{
echo "Usage: $0 <projectname> [configuration] [logname]"
echo "<projectname> name of your .xcodeproj file (and your .app as well)"
echo "[configuration] (optional) Debug or Release, defaults to Debug"
echo "[logname] (optional) the log file to write to. defaults to stderror.log"
}
 
# check first argument
if [ -z "$PROJECTNAME" ] ; then
help
exit 1
fi
 
# check second argument, default to "Debug"
if [ -z "$CONFIGURATION" ] ; then
CONFIGURATION=Debug
fi
 
# check third argument, default to "stderror.log"
if [ -z "$LOGFILE" ] ; then
LOGFILE=stderr.log
fi
 
# backup existing logfile (start fresh each time)
if [ -f $LOGFILE ]; then
mv $LOGFILE $LOGFILE.bak
fi
 
touch -cm www
xcodebuild -configuration $CONFIGURATION -sdk iphonesimulator -project $PROJECTNAME.xcodeproj
ios-sim launch build/$CONFIGURATION-iphonesimulator/$PROJECTNAME.app --stderr $LOGFILE --exit
osascript -e "tell application \"iPhone Simulator\" to activate"
tail -f $LOGFILE

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.