Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read the Bundle version from PList?

Tags:

iphone

Is there a way to read the app's bundled plist file, I am wanting to pull the value for Bundle version.

like image 993
Rob Bonner Avatar asked Feb 11 '10 14:02

Rob Bonner


People also ask

Does the bundle contain an info plist?

plist does not contain a CFBundleVersion (Bundle version) key or a CFBundleShortVersionString (Bundle versions string, short) key. Your app must provide and set both of these keys.

What is bundle version string?

Bundle versions string, short (CFBundleShortVersionString) is a number comprising of three integers separated by dots. First one represents any major updates of the application, such as updates that implement new features or major changes. The second integer denotes revisions that implement less prominent features.

What is in Info plist?

plist is a place to store information about your app, e.g., App name, app version, and build number. You might want to use this information somewhere like About view or attached them in troubleshooting.


2 Answers

See Getting the Bundle’s Info.plist Data.

[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]; 

should get you the bundle version.

like image 55
Ole Begemann Avatar answered Sep 26 '22 10:09

Ole Begemann


In Swift you can use:

let bundleVersion = Bundle.main.object(forInfoDictionaryKeykCFBundleVersionKey as String) as! String 

or:

let bundleVersion = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as! String 

If you want the short bundle versions string, you can use:

let shortBundleVersion = Bundle.main.object(forInfoDictionaryKey:"CFBundleShortVersionString") as! String 
like image 37
PassKit Avatar answered Sep 23 '22 10:09

PassKit