Skip to content

Instantly share code, notes, and snippets.

@wessmith
Last active August 29, 2015 14:01
Show Gist options
  • Save wessmith/5999fedf18fc544bca6a to your computer and use it in GitHub Desktop.
Save wessmith/5999fedf18fc544bca6a to your computer and use it in GitHub Desktop.
pod install post-checkout script
#!/bin/bash
PREVIOUS_HEAD=$1
NEW_HEAD=$2
BRANCH_SWITCH=$3
if [[ $BRANCH_SWITCH == "1" && $PREVIOUS_HEAD != $NEW_HEAD ]]; then
# Kill the simulator.
SIM=`pgrep 'iPhone Simulator'`
if [[ "'$SIM'" != "" ]]; then
osascript -e 'tell application "iPhone Simulator" to quit'
fi
XCODE=`pgrep 'Xcode'`
if [[ "'$XCODE'" != "" ]]; then
WORKSPACE=`osascript -e 'tell application "Xcode" to get name of active workspace document' 2> /dev/null`
osascript -e 'tell application "Xcode" to close active workspace document'
fi
# Check if pods need to be installed.
diff "Podfile.lock" "Pods/Manifest.lock" > /dev/null 2>&1
if [[ $? != 0 ]]; then
echo "Pods are out of sync. Installing pods..."
pod install
if [[ $? -eq 0 ]]; then
echo "Pods are now up to date."
fi
else
echo "Pods are already up to date."
fi
if [[ "$WORKSPACE" == *xcworkspace ]]; then
open $WORKSPACE
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment