欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

获取APP版本号

程序员文章站 2022-05-19 22:10:29
...
var appVersion: String {
    var result = ""
    if let info = Bundle.main.infoDictionary {
        if let version = info["CFBundleShortVersionString"] as? String {
            result = version
            if let build = info["CFBundleVersion"] as? String {
                result = "V" + version + " (Build " + build + ")"
            }
        } else {
            result = "V1.0.0 (Build 1)"
        }
    }
    return result
}