Update on 2013-08-24: If you need a solution for Android, check out this post.
Update on 2013-06-09: I’ve updated the plist_build_info.sh script so that it inserts the tag for the commit, if you’re not on a branch now.
It’s a very useful feature when the build process automatically stores the build info (e.g., date, time, git branch and commit hash), so that it can be read from your app in runtime.
It’s quite easy to do in Xcode, here’s a script for that:
Download it to the directory where your .xcodeproj/.xcworkspace file is. Open the project/workspace in Xcode, (optional) add the script to the Supporting Files group, but uncheck its target membership on the right:
Click the project on the left, then select your target, Build Phases tab, click the Add Build Phase button at the bottom, select Add Run Script menuitem, (recommended) rename the added step to 'Save build info into info.plist', and set the command to ${SRCROOT}/plist_build_info.sh:
Don’t forget to open the app’s plist file (YourProject-Info.plist) and add an empty row with key = BuildTime and type = String: