Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

swift get app version and build

import Foundation

extension Bundle {

    var shortVersion: String {
        if let result = infoDictionary?["CFBundleShortVersionString"] as? String {
            return result
        } else {
            assert(false)
            return ""
        }
    }

    var buildVersion: String {
        if let result = infoDictionary?["CFBundleVersion"] as? String {
            return result
        } else {
            assert(false)
            return ""
        }
    }

    var fullVersion: String {
        return "(shortVersion)((buildVersion))"
    }
}

// Usage:

someLabel.text = Bundle.main.versionNumber
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #swift #app #version #build
ADD COMMENT
Topic
Name
3+9 =