Created
February 5, 2015 17:31
-
-
Save adamyanalunas/5a69008bc9f249a6981e to your computer and use it in GitHub Desktop.
A git post-install to update your pods, if needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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