Return to   |   Check out   |   How to Post Snippets  

Not registered? Thats okay! You can Submit a Snippet without being a member of this site!

*    141votes

Here is a nice way to increment the build number for your app. Every time you build your project this will add a number to CFBundleVersion. This also adds the build time and date to your info.plist. In order for this to work, you need to add a new entry to your plist called CFBuildDate, otherwise the compiler will not continue past the run script phase.

First you will want to go to your Project Target:

Second, click on Build Phases:

Third, click on Add Build Phase:

and select Add Run Script:

This should give you a new empty Run Script box so you can enter your shell script code:

Paste the below code in this box.

Note: Also check the “Run script only when installing”. This way you do end up with a ton of increments just from pressing build.

Now each time you build your project, the Build number will increment.


## This will point to YourProject-Info.plist, no need to change this.
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${SRCROOT}/${INFOPLIST_FILE}")

## Increment the build by 1
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${SRCROOT}/${INFOPLIST_FILE}"

## Update the build date
/usr/libexec/PlistBuddy -c "Set :CFBuildDate $buildDate" "${SRCROOT}/${INFOPLIST_FILE}"

Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

© Copyright 2011 Wright's Computer Services.   All rights reserved Suffusion theme by Sayontan Sinha