开发者

How to read the Bundle version from PList?

开发者 https://www.devze.com 2022-12-19 17:59 出处:网络
Is there a way to read the app\'s bundled plist file, I am want开发者_如何学编程ing to pull the value for Bundle version.See Getting the Bundle’s Info.plist Data.

Is there a way to read the app's bundled plist file, I am want开发者_如何学编程ing to pull the value for Bundle version.


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


#define APP_VERSION [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey] 
0

精彩评论

暂无评论...
验证码 换一张
取 消