Skip to content

Instantly share code, notes, and snippets.

@jokefaker
Last active August 29, 2015 14:14
Show Gist options
  • Save jokefaker/4abd5eefa54e4f40eae2 to your computer and use it in GitHub Desktop.
Save jokefaker/4abd5eefa54e4f40eae2 to your computer and use it in GitHub Desktop.
Update Xcode build and version numbers from git
git=`sh /etc/profile; which git`
appBuild=`"$git" rev-list --all |wc -l`
appVersion=`"$git" describe --abbrev=0 --tags`
# set the commit count as app's build,add branch-name as suffix when using debug model
if [ $CONFIGURATION = "Debug" ]; then
branchName=`"$git" rev-parse --abbrev-ref HEAD`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild-$branchName" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
else
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
# set the last git tag as app's version
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $appVersion" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
fi
echo "Updated ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment