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 :: how to remove background color for uibutton swift 
Swift :: swift firebase read key in autoKey 
Swift :: access dictionary with index swift 
Swift :: swift rotate text 90 degrees 
Swift :: how to swift pie chart quartzcore framework 
Swift :: swift compare string to button title 
Swift :: cgrect swift 
Swift :: swift get a rectangle centered 
Swift :: how to make a image flip swift 
Swift :: ionic Library not found for -lGoogleToolboxForMac 
Swift :: swift access appdelegate from viewcontroller 
Swift :: swift filter dictionary 
Swift :: Properties Swift 
Swift :: swift url encode string 
Swift :: swiftui pull to refresh 
Swift :: swift scroll to tableviewcell 
Swift :: swift order dictionary by key 
Swift :: How to find index of list item in Swift? 
Swift :: power swift 
Swift :: set right bar button item swift 
Swift :: Swift Closure That Returns Value 
Swift :: uitextview text alignment 
Swift :: add callbacks to view swiftui 
Swift :: How to convert String into Array of character 
Swift :: parse int in swift 
Swift :: Swift Handling Errors Using do-catch Statement 
Swift :: swift 5 touchupinsideview 
Swift :: how to debug before app launch swift 
Swift :: procedural audio with swift 
Swift :: swift for loop with where caluse 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =