Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift get app version and build

let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
Comment

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
Comment

swift 5 get app version

import Foundation

let versionString = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "Default String to shut up warning"
let buildString = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "Default String to shut up warning"
Comment

PREVIOUS NEXT
Code Example
Swift :: swift screenshot 
Swift :: set white place holder color in swift 
Swift :: swft image 
Swift :: ios make http request 
Swift :: uitextview set placeholder text swift 5 
Swift :: dismiss keyboard on tap outside swiftui 
Swift :: swift change navigation bar title 
Swift :: swift constructor 
Swift :: how to get the path of selected PDF/doc from file manager in ios swift programmatically 
Swift :: how to Not bool bindng swiftui 
Swift :: how to show notification icon on tabbar item swift 
Swift :: swift extension Array with type 
Swift :: how to add corner in swiftui 
Swift :: while loop in swift 
Swift :: swft view 
Swift :: Swift Half-Open Range 
Swift :: swift arkit texture face get position on screen 
Swift :: swift disable modal dismiss swift 
Swift :: UIApplicationWillEnterForeground 
Swift :: swift md5 cryptokit 
Swift :: swift reading binary data 
Swift :: swiftui polygon 
Swift :: Swift Explicitly declaring an unwrapped optional 
Swift :: how to stack align label over a card in flutter 
Swift :: swift isMemberOf 
Swift :: Swift Conforming Multiple Protocols 
Swift :: Swift Nil-coalescing operator 
Ruby :: validates length rails 
Ruby :: rails hidden field 
Ruby :: rails routes grep 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =