Last active
December 17, 2015 15:48
-
-
Save SergioEstevao/5633908 to your computer and use it in GitHub Desktop.
XCode Build and Version numbers based on GIT
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
# grabbing version number from the info.plist of the app | |
COMERCIAL_VERSION=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" Info.plist` | |
# grabbing number of commits in the current branch to create a version number | |
BUILD_VERSION=`git rev-list HEAD | wc -l | tr -d ' ' | tr -d '\n'` | |
# grabbing the commit hash for future reference | |
GIT_VERSION=`git show --abbrev-commit | grep '^commit' | sed 's/commit //' | tr -d '\n'` | |
# export values to preprocessor file | |
echo "#define GIT_VERSION $GIT_VERSION" > InfoPlist.h | |
echo "#define BUILD_VERSION $COMERCIAL_VERSION.$BUILD_VERSION" >> InfoPlist.h | |
# make sure the Info.plist is reprocessed by the compiler | |
touch Info.plist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment