Skip to content

Instantly share code, notes, and snippets.

@SergioEstevao
Last active December 17, 2015 15:48
Show Gist options
  • Save SergioEstevao/5633908 to your computer and use it in GitHub Desktop.
Save SergioEstevao/5633908 to your computer and use it in GitHub Desktop.
XCode Build and Version numbers based on GIT
# 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