I’m using Xcode 4 in combination with Git and would like to increment the CFBundleVersion in Info.plist on each build. The value for the key CFBundleVersion should be updated to the number of the last commit I made to the Git repository.
I found that python script which works well, but unfortunately doesn’t update the Info.plist in my Xcode project – it just updates the Info.plist in the “BUILT_PRODUCTS_DIR”.
Does anyone has an idea how to get Xcode 4 to fetch the version of the latest commit and put that information into the project’s Info.plist?
Thanks!
The version string needs to be of the format [xx].[yy].[zz] where x, y, z are numbers.
I deal with this by using
git tagto give specific commits meaningful tag numbers for x and y (eg 0.4), and then via a script build phase, z gets the number of commits since the last tag, as returned bygit describe.Here’s the script, which I adapted from this one. It can be added straight to the target as a build phase (
shellis/usr/bin/env ruby):