How to read the Bundle version from PList?

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

See Getting the Bundle’s Info.plist Data.

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

should get you the bundle version.

Tags:

Iphone