Tuesday, January 4, 2011

How to Update CFBundleVersion Before Building Application

Used to update application version number in appDelegate.m during startup. The problem was that user has to run the application at least once to update version number in system Settings application.

Before that moment version number was either missing or wrong, depending on what the default value was. Not good.

Suddenly realized that Info.plist is a plain text file and could be modified just right before application is created! Here's some python code:
import plistlib
pl = plistlib.readPlist("Info.plist")
pl["CFBundleVersion"] = "1.1"
Very simple, even if I say so myself.  In real life I use project's SVN revision number to generate a dynamic version number, but that's another story.

No comments:

Post a Comment