Created
October 9, 2018 00:42
-
-
Save bulwinkel/cb19bc13581359e18c2b3bd69febcadf to your computer and use it in GitHub Desktop.
iOS Git Versioning
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
#!/usr/bin/env bash | |
# set-version-from-git.sh | |
# Usage: `set-version-from-git.sh [branch]` | |
# Run this script after the 'Copy Bundle Resources' build phase | |
# Ref: http://tgoode.com/2014/06/05/sensible-way-increment-bundle-version-cfbundleversion-xcode/ | |
# Sets the build and version numbers in the compiled app bundle so it doesn't | |
# modify your version controlled info.plist | |
branch=${1:-'master'} | |
buildNumber=$(expr $(git rev-list $branch --count) - $(git rev-list HEAD..$branch --count)) | |
echo "Updating build number to $buildNumber using branch '$branch'." | |
versionNumber=$(git describe --tags) | |
echo "Version from tag: $versionNumber" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $versionNumber" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
if [ -f "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}.dSYM/Contents/Info.plist" ]; then | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}.dSYM/Contents/Info.plist" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $versionNumber" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}.dSYM/Contents/Info.plist" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment