Skip to content

Instantly share code, notes, and snippets.

@nicnocquee
Created July 9, 2016 20:01
Show Gist options
  • Select an option

  • Save nicnocquee/0e0de8a26a287f081338f5dbcaec646f to your computer and use it in GitHub Desktop.

Select an option

Save nicnocquee/0e0de8a26a287f081338f5dbcaec646f to your computer and use it in GitHub Desktop.
Boot or reboot iOS simulator
#!/bin/bash
BOOTING="Booting "
if [ $# -eq 0 ]
then
SIMULATOR=$(xcrun simctl list | grep Booted | cut -d$'\n' -f1 | cut -d "(" -f2 | cut -d ")" -f1)
if [ ! -z "$SIMULATOR" ]; then
SIMULATORNAME=$(xcrun instruments -s | grep $SIMULATOR | cut -d "[" -f1)
BOOTING="Rebooting $SIMULATORNAME"
fi
else
SIMULATOR=$1
BOOTING="Booting $SIMULATOR"
fi
if [ -z "$SIMULATOR" ]; then
echo "No running simulator. You need to specify device: $0 \"iPhone 6 (9.3)\""
exit
fi
echo $BOOTING
killall Simulator > /dev/null 2>&1
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID $(xcrun instruments -s | grep "$SIMULATOR" | grep -v "Apple Watch" | cut -d "[" -f2 | cut -d "]" -f1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment