Created
May 5, 2025 15:19
-
-
Save mccaffers/df35b47e3910279c0f0c7c2bb261c914 to your computer and use it in GitHub Desktop.
This script updates an iOS app's Info.plist file with the current Git commit hash, creating the GitCommitHashApp key if it doesn't already exist. Useful for reference the git hash inside the Swift application.
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
| INFO_PLIST="${TARGET_BUILD_DIR}"/"${INFOPLIST_PATH}" | |
| # Get the GIT hashes | |
| searchOpsApp=$(git rev-parse --short HEAD) | |
| # Query and save the value; suppress any error message, if key not found. | |
| valueApp=$(/usr/libexec/PlistBuddy -c 'print :GitCommitHashApp' "${INFO_PLIST}" 2>/dev/null) | |
| # Check if value is empty | |
| if [ -z "$valueApp" ] | |
| then | |
| /usr/libexec/PlistBuddy -c "Add :GitCommitHashApp string" "${INFO_PLIST}" | |
| fi | |
| /usr/libexec/PlistBuddy -c "Set :GitCommitHashApp `echo $searchOpsApp`" "${INFO_PLIST}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment