Automatic Git Revision Stamping for App Store Projects

Posted by on Nov 2, 2010 in Blog | Tags: , , , , , | No Comments

Following up on my post about automatic Subversion revision stamping, here is a modified script for use with Git-based projects.

I’ve been moving toward Git for more of my work, for mostly two reasons. The first is that Subversion uses “@” to denote a specific revision of a file, which makes adding images for the Retina Display annoying because they use “@2x” in the file name. The second is that integrating third-party source into a project is more work than it should be because Subversion litters the tree with .svn directories. I can’t simply delete the old third-party source and drop in the new files, because Subversion loses its state. Yes, I could svn rm, then svn add, but that grows the repository unnecessarily and I lose the ability to diff the source and see what actually changed.

Git does not use a numeric repository version, however, and a simple SHA1 hash is unsuitable for use as the third component of a bundle version because it can include the letters a-f. I took the simplest way out and use a file (build-counter) with a number in it, incremented for every Ad Hoc and App Store build, but not for Debug or Release. This file is created if it does not exist and automatically committed.

As with my Subversion script, if any local modifications are detected during an Ad Hoc or App Store build, it will fail.

Since it’s likely that Apple will enforce the same format restrictions on Mac App Store apps, this script can also be used in those projects.