Is there a way to read the app's bundled plist file, I am wanting to pull the value for Bundle version.
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.
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.
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.
See Getting the Bundle’s Info.plist Data.
[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
should get you the bundle version.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With