[英]How to read the Bundle version from PList?
有没有办法读取应用程序的捆绑plist文件,我想拉取Bundle版本的值。
[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
应该得到捆绑版本。
在Swift中你可以使用:
let bundleVersion = Bundle.main.object(forInfoDictionaryKeykCFBundleVersionKey as String) as! String
要么:
let bundleVersion = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as! String
如果需要短包版本字符串,可以使用:
let shortBundleVersion = Bundle.main.object(forInfoDictionaryKey:"CFBundleShortVersionString") as! String
#define APP_VERSION [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.