Last active
December 15, 2015 21:09
-
-
Save joshbuhler/5323194 to your computer and use it in GitHub Desktop.
This will automatically bump the build number of your project's info.plist file when creating an archive for distribution of your app. To use, add this script as a "Run Script" phase to your Xcode build phases, *before* the "Copy Bundle Resources" phase. (It needs to be here so that the updated info.plist file will be copied into the new archive…
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 | |
################################################## | |
# | |
# BuildVersion incrementing script v1.0 | |
# | |
################################################## | |
processedPlist="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
projectPlist="${INFOPLIST_FILE}" | |
versionVar="CFBundleVersion" | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print ${versionVar}" "${projectPlist}" 2>&1) | |
if [[ "$buildNumber" == *Does\ Not\ Exist ]] ; then | |
buildNumber=1 | |
echo "Create ${versionVar} and set to ${buildNumber}" | |
/usr/libexec/PlistBuddy -c "Add :${versionVar} String ${buildNumber}" "${processedPlist}" | |
/usr/libexec/PlistBuddy -c "Add :${versionVar} String ${buildNumber}" "${projectPlist}" | |
else | |
buildNumber=$(($buildNumber + 1)) | |
echo "set ${versionVar} to ${buildNumber}" | |
/usr/libexec/PlistBuddy -c "Set :${versionVar} ${buildNumber}" "${processedPlist}" | |
/usr/libexec/PlistBuddy -c "Set :${versionVar} ${buildNumber}" "${projectPlist}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment