Acerbic Resonance

There’s no substitute for a good subtitle.

How To Detect iPhone App Version At Runtime?

I’m currently working on an application that will need to know what version of the app is currently running.  For instance, when I release version 1.2 of the app, I may need to update files that were left behind by version 1.1, but only do the update one time – the first time version 1.2 is ever launched.

I puzzled over how to detect the current version of my running app at runtime for a bit, and after digging around in the SDK documentation, I discovered that you can get access to the contents of the info.plist file that is used by your application bundle.  All you have to do is ask the bundle to pretty please tell you the value of the bundle version.

Like this:

NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];

NSLog(@"Starting application database handler.  Detected app version %@", appVersion);


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *