Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to read the 'current project version' in the settings of an iPhone app

In my app I am using the agvtool to update the build number. I would now like to have the version of my app that appears in the settings to display this number and have it update automatically.

I have seen a few apps work around this by writing a script to ready the value and populate the value then in the root.plist. I was wondering if there is a more elegant way of doing this.

like image 646
Liam Avatar asked Oct 24 '25 09:10

Liam


2 Answers

I don't know your agvtool but the way I get my application version from the code is :

[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];

This gets the version number from the info.plist that you have to define before uploading your app to iTunesConnect, so this should be ok : you rely on a value that you have to define anyway.

like image 166
yonel Avatar answered Oct 26 '25 06:10

yonel


You are looking for this. It includes information on how to set up and manage your marketing version and build number information. Then, when you need the build string, do something akin to the following:

NSString *marketingVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSString *buildNumber = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];

self.appVersionLabel.text = [NSString stringWithFormat:@"%@.%@", marketingVersion, buildNumber];
like image 39
Ken Wootton Avatar answered Oct 26 '25 08:10

Ken Wootton