Skip to content

Instantly share code, notes, and snippets.

@ericholsinger
Created December 12, 2013 18:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericholsinger/7932505 to your computer and use it in GitHub Desktop.
Save ericholsinger/7932505 to your computer and use it in GitHub Desktop.
This is a script for incrementing build numbers in xcode, automatically during the build phase. It handles the build in the format xx.yy.zz where zz is incremented for each build, and yy is incremented when you archive your project. The xx is handled manually in this case. For more information, you can read my blog post at http://bit.ly/1h3ztJK
#!/bin/bash
conf=${CONFIGURATION}
arch=${ARCHS:0:4}
# Only increase the build number on Device and AdHoc/AppStore build
if [ $conf == "Release" ]
then
echo "Bumping bundle version number..."
buildPlist=${INFOPLIST_FILE}
bundleVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$buildPlist" | /usr/bin/perl -pe 's/(\d+\.)(\d+)(\.\d+)/$1.($2+1).$3/eg'`
echo $bundleVersion;
/usr/libexec/PListBuddy -c "Set :CFBundleVersion $bundleVersion" "$buildPlist"
echo "Bumping bundle short version number..."
bundleShortVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$buildPlist" | /usr/bin/perl -pe 's/(\d+\.)(\d+)/$1.($2+1)/eg'`
echo $bundleShortVersion;
/usr/libexec/PListBuddy -c "Set :CFBundleShortVersionString $bundleShortVersion" "$buildPlist"
else
echo "Bumping bundle version number..."
buildPlist=${INFOPLIST_FILE}
echo "${INFOPLIST_FILE}"
bundleVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$buildPlist" | /usr/bin/perl -pe 's/(\d+\.\d+\.)(\d+)/$1.($2+1)/eg'`
echo $bundleVersion;
/usr/libexec/PListBuddy -c "Set :CFBundleVersion $bundleVersion" "$buildPlist"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment