Last active
October 16, 2018 10:31
-
-
Save samermurad/b0133d104e762293aa2cc65e3d82f70e to your computer and use it in GitHub Desktop.
Add Git Hash to iOS App plist: Put this code under a new "run script" in Project>Target>Run Phases> Create new run script
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/sh | |
gitHash=$(/usr/libexec/PlistBuddy -c "Print :GitHash" "${PROJECT_DIR}/${INFOPLIST_FILE}") | |
exitCode=$? | |
if [ $exitCode == 0 ]; then | |
gitHash=$(git rev-parse HEAD | cut -c1-10) | |
/usr/libexec/PlistBuddy -c "Set :GitHash $gitHash" "${PROJECT_DIR}/${INFOPLIST_FILE}" | |
else | |
gitHash=$(git rev-parse HEAD | cut -c1-10) | |
/usr/libexec/PlistBuddy -c "Add :GitHash string $gitHash" "${PROJECT_DIR}/${INFOPLIST_FILE}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment