Auto-increment Build Number in Xcode


When building and releasing iOS apps, I used to manually update the build number of the app. However, I found this great script that will automatically increment the build number each time you build the app.

Date as build number

However, that script will increment the build number by one each time the app is build. I prefer to have a date stamp, so that I can immediately see when a build was performed. I therefore use a build number with a date format: “yyyymmddHHMM”.

To make this work, I replaced the default builnum value with this one:

buildnum=`date +%Y%m%d%H%M`

This will set the build number to a timestamp instead of incrementing it by one.

Run script permissions

Initially, XCode may have problems executing your script. For this to work, you will need to enable run access. Do so by running the following terminal script:

sudo chmod 755 'filename'

Execute it in the same folder as the shell script, and you should be good to go.