Automatically use the latest mercurial changeset id as CFBundleVersion
Sponsored Links:
Updating Info.Plist Bundle Version from Mercurial Changeset ID at Build Time
How To
Create a new ‘Run Script’ Build Phase in your target. Set the Shell field to /usr/bin/python
#!/usr/env/python
from AppKit import NSMutableDictionary
import subprocess
import os
def increaseVersion():
# reading hg version
# use the line below instead if you want the full 40 character node id
# p1 = subprocess.Popen(["/usr/local/bin/hg","--debug","id", "-i"], stdout=subprocess.PIPE)
p1 = subprocess.Popen(["/usr/local/bin/hg","id", "-i"], stdout=subprocess.PIPE)
version = p1.communicate()[0].strip()
print('version: '+repr(version))
# reading info.plist file
projectPlist = NSMutableDictionary.dictionaryWithContentsOfFile_('Info.plist')
# setting the svn version for CFBundleVersion key
projectPlist['CFBundleVersion'] = version
projectPlist.writeToFile_atomically_('Info.plist', True)
os.utime('Info.plist', None)
if __name__ == '__main__':
increaseVersion()