objc:
+ (NSString*) getAppVersionName
{
return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
}
+ (NSString*) getAppBuildVersionCode
{
return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
}
swift:
var version: String? {
guard let dictionary = Bundle.main.infoDictionary,
let version = dictionary["CFBundleShortVersionString"] as? String,
let build = dictionary["CFBundleVersion"] as? String else {return nil}
let versionAndBuild: String = "vserion: \(version), build: \(build)"
return versionAndBuild
}
출처
https://stackoverflow.com/questions/24501288/getting-version-and-build-information-with-swift