Xcode, incrementing build numbers and version numbers for releases

How to add a build number increment phase to you ios project in xcode

By: Procsilas Moscas

I like nice neat build numbers. I don’t like manually maintaining text fields.

To that end, I modified a nice lead on a build number increment script to suit my needs. Maybe it will help you, too.

First, I need to give credit to the giants upon whose shoulders I stand: http://stackoverflow.com/questions/6286937/how-to-auto-increment-bundle-version-in-xcode-4

I was able to cobble together my build number phase based upon information shared in that stack overflow page, and probably others.

Second, I need to explain my build number scheme.

I use Testflight to distribute my apps for testing.

On the Summary view, I use a #.# Version and a #.#.# Build. The first digit represents a major version; usually a version number for each customer request. The second digit is a release to users for testing. The 3rd digit of the build resets to zero upon a release (ex: 2.0.1, 2.0.2, 2.1.0, 2.1.1) but otherwise increments each time I compile and run the app.

To use the script, click on your project then choose build phases.

On the bottom right, click Add Build Phase and choose Add Run Script.

Copy and paste the following into the shell script contents:

The code should appear above between the two lines, if it’s not visible, refresh or view the script in gist.

Make sure your change your build Summary to reflect the build number pattern (1.0 in Version and 1.0.0 in Build, for example).

When you compile, the Build will increment the third digit. When you Archive, the build will increment the second digit and reset the third digit to zero.

Author: Eric Holsinger

Eric Holsinger is a software professional and photography enthusiast in Southern Maine.

Leave a Reply