Here’s a handy tip for, as the title says,
Auto-incrementing Build Numbers in Xcode
What we want to do is to have the build number available in our Info.plist file, so that it can be read and displayed at run-time. And we also want Xcode to automatically increment this number for every build.
Add a key named CWBuildNumber to your Info.plist file, and set it to a sane start value, maybe “0″… Secondly we want to rewrite the target’s source Info.plist file, not the file bundled with the application, so make sure to order the script phase before the Copy Resources phase. Then just add this tiny script phase to your target build:
Works nicely no doubt, but around here we don’t want every build to auto-increment exactly; how we like to set our projects up is that in Info.plist CFBundleShortVersionString is the version string displayed in the App Store, “1.0″ and so forth, whilst CFBundleVersion is the number of the Subversion revision it was built with. Makes matching up code with bug reports trivial, that does. And the script there is applicable to that strategy too; just instead of incrementing by 1, set it to the output of svnversion:
svnversion is a program for summarizing the revision mixture of a working copy. The resultant revision number, or revision range, is written to standard output.
It’s common to use this output in your build process when defining the version number of your program…
Not so common in the iOS world, especially since everyone and their dog seems to use git these days for no compelling reason we can figure out; but it works nicely for us to identify the code that goes with a given build instantly.
Continue Reading →