Skip to content

How To Detect iPhone App Version At Runtime?

by kimball on November 12th, 2009

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);

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS

Spam protection by WP Captcha-Free