Skip to content

Instantly share code, notes, and snippets.

@adamyanalunas
Created February 5, 2015 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamyanalunas/5a69008bc9f249a6981e to your computer and use it in GitHub Desktop.
Save adamyanalunas/5a69008bc9f249a6981e to your computer and use it in GitHub Desktop.
A git post-install to update your pods, if needed
#!/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