How to read the Bundle version from PList?

Is there a way to read the plist file associated with the application, I want to pull the value for the Bundle version.

+48
iphone
Feb 11 2018-10-11
source share
3 answers

See Getting Data Bundles Info.plist .

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

should provide you the package version.

+121
Feb 11 2018-10-11T00
source share

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 need a short string version string, you can use:

 let shortBundleVersion = Bundle.main.object(forInfoDictionaryKey:"CFBundleShortVersionString") as! String 
+14
Nov 30 '14 at 7:41
source share
 #define APP_VERSION [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey] 
-one
Sep 24 '15 at 7:51
source share



All Articles