In the iOS world, you want to keep you build number unique (CFBundleVersion). When submitting an app to the App Store, Apple will check that your have not submitted a build with the same number before. The build number also needs to be greater than your previous build numbers. Else Apple will reject it.

So how do you keep this number straight when using a git branching model?

You can obviously keep track of the build number by hand and increment it yourself, but I find this cumbersome. You can write a script that will bump your build number every time you build in Xcode, but in my experience that starts to break down when you have multiple developers building different releases which are each on their own branch.

So today I'll walk you through a process where build number are kept in a central location so that when you create a new build you can always be sure your build number is unique.

First off, you need to pick which branch will hold the truth. In this exemple I'll use develop.

The first task when creating a new build, will be to go check on develop what the latest build number is and increment it.