Last active
April 20, 2016 09:44
-
-
Save reejosamuel/dfdb9c49bb398a01962b5700fc257070 to your computer and use it in GitHub Desktop.
Auto Increment Build Number in iOS
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
# | |
# Set the build number to the current git commit count. | |
# If we're using the Dev scheme, then we'll suffix the build | |
# number with the current branch name, to make collisions | |
# far less likely across feature branches. | |
# Based on: http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/ | |
# | |
# Updated with dSYM handling from http://yellowfeather.co.uk/blog/auto-incrementing-build-number-in-xcode-revisited/ | |
# | |
git=`sh /etc/profile; which git` | |
appBuild=`"$git" rev-list HEAD --count` | |
if [ $CONFIGURATION = "Debug" ]; then | |
branchName=`"$git" rev-parse --abbrev-ref HEAD` | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild-$branchName" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild-$branchName" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/Info.plist" | |
else | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/Info.plist" | |
fi | |
# echo "Target Build Path: ${TARGET_BUILD_DIR}" | |
# echo "Info Plist Path: ${INFOPLIST_PATH}" | |
echo "BUILT_PRODUCTS_DIR: ${BUILT_PRODUCTS_DIR}" | |
echo "WRAPPER_NAME: ${WRAPPER_NAME}" | |
echo "Incremented the build number ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment