Created
February 17, 2012 18:54
-
-
Save megawertz/1854848 to your computer and use it in GitHub Desktop.
Auto-Version Xcode Projects Using Git Tags & Commits
This file contains 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
# Sets the CFBundleShortVersionString of the Xcode project to the last git tag | |
# Sets the CFBundleVersion number to one of 3 options below | |
git=/usr/bin/git | |
fullVersion=`$git describe --dirty` | |
# Use the most recent git tag for the CFBundleShortVersionString | |
appVersion=`echo $fullVersion | cut -d '-' -f1 | sed 's/v//'` | |
# Use the most recent commit hash for CFBundleVersion | |
# buildNumber=`echo $fullVersion | cut -d '-' -f2` | |
# Use total of all commits and not just commits since last tag for CFBundleVersion | |
# buildNumber=`git rev-list --all | wc -l` | |
# Increment previous build number by 1 for CFBundleVersion | |
buildNumber=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$INFOPLIST_FILE"` | |
let buildNumber=$buildNumber+1 | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $appVersion" "$INFOPLIST_FILE" | |
# Based on code found here | |
# http://www.icodeblog.com/2011/03/23/using-git-versioning-inside-your-xcode-project/ | |
# and here | |
# http://stackoverflow.com/questions/6851660/version-vs-build-in-xcode-4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment