How to read you App Version and Build from the Main Bundle

The required Version and Build numbers you add to Xcode make it into your app’s Main Bundle. You can retrieve those values from the Main Bundle and use them in your app.

Here’s how:

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    // set version and build fields from bundle
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    NSString *build = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
    
    // display in your own labels
    self.versionLabel.text = version;
    self.buildLabel.text = build;

}

iTunes Connect reads both of these. Your “new version” is what’s displayed in the App Store, while the build is a more arbitrary thing you can set yourself.

Note that both values are floats, and that you need to increase them with every version. If you decrease either of them, iTunes Connect will complain next time you submit a build.





Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.