Last active
February 14, 2017 23:17
-
-
Save foundry/9da322636babaf948c3480082d407d0d to your computer and use it in GitHub Desktop.
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
# https://gist.github.com/sekati/3172554 | |
# xcode-build-bump.sh | |
# @desc Auto-increment the build number every time the project is run. | |
# @usage | |
# 1. Select: your Target in Xcode | |
# 2. Select: Build Phases Tab | |
# 3. Select: Add Build Phase -> Add Run Script | |
# 4. Paste code below in to new "Run Script" section | |
# 5. Drag the "Run Script" below "Link Binaries With Libraries" | |
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0) | |
git=`sh /etc/profile; which git` | |
appBuild=`"$git" rev-list HEAD --count` | |
commitSha=`"$git" log -1 --oneline | cut -c 1-7` | |
copyright="© 2017 VEEPIO LLC" | |
if [ $CONFIGURATION = "Debug" ]; then | |
branchName=`"$git" rev-parse --abbrev-ref HEAD` | |
#buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}") | |
#buildNumber=$(($buildNumber + 1)) | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild-$branchName" "${PROJECT_DIR}/${INFOPLIST_FILE}" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild-$branchName" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}.dSYM/Contents/Info.plist" | |
else | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${PROJECT_DIR}/${INFOPLIST_FILE}" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}.dSYM/Contents/Info.plist" | |
fi | |
shortVersionString=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}") | |
cut -c 7 | |
humanReadableCopyright="$copyright $shortVersionString-$appBuild ($commitSha)" | |
/usr/libexec/PlistBuddy -c "Set :NSHumanReadableCopyright $humanReadableCopyright" "${PROJECT_DIR}/${INFOPLIST_FILE}" | |
echo "Incremented the build number and copyright ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment