iOS – Pull App Version From Bundle Configuration

We all like to put the current application version number in an “about” screen somewhere for users to reference.  It’s a pain, however, to have to update that screen every time we do a release as well as the version in the target configuration for the bundle.  So why not pull the version number from the bundle?  Here’s how to do it:
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleVersionKey];

NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

Just put this version number in your label programatically and you’re set!  Since my About screen is in a nib/xib, I set the label text to “Version x.x” so I would understand the label isn’t static next time I look at the screen in Interface Builder.

— UPDATED 3/9/2012

I updated this post with a recent change to the way version numbers work.  Not sure if this was an advertised change by Apple, but this should fix any issues you have.

4 thoughts on “iOS – Pull App Version From Bundle Configuration

  1. Tim

    This does not work for me. It returns the Build number NOT the version number.

    If I use the code provided and my app is Version 1.0 Build 56 I get “56” returned, not “1.0” this happens on both iOS 4.3 and 5.x


  2. Aaron

    I forgot to update this post – try this –

    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@”CFBundleShortVersionString”];
    NSString *versionLabelText = [NSString stringWithFormat:@”Version %@”, version];


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s