How to read the Bundle version from PList?

Solution 1:

See Getting the Bundle’s Info.plist Data.

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

should get you the bundle version.

Solution 2:

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