Skip to content

Instantly share code, notes, and snippets.

@elmodos

elmodos/revision.sh

Last active Mar 31, 2016
Embed
What would you like to do?
Add this script to Build Phases of your target in Xcode to automatically set build number with SVN/Git revision number
# set build number only for release (Product|Archive)
if [ "$CONFIGURATION" == "Release" ]; then
# get GIT revision number
buildNumber=`git rev-list --count HEAD`
# if not git, then get SVN revision number
if [[ -z "$buildNumber" ]]; then
buildNumber=`svn info | grep "Revision" | awk '{print $2}'`
fi
# set default value if no rev number found
if [[ -z "$buildNumber" ]]; then buildNumber=1; fi
# write build number into project plit file
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${buildNumber}" "${INFOPLIST_FILE}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment