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
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? Stringimport 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
Also in Swift:
- how to get appdelegate object in swift
- swift filter dictionary
- how to dismiss keyboard swiftui
- add shadow to UIButton swift
- swift set uiimage color
- how to insert element at start of the array ios swift
- get device name swift
- show back button in navbar swift
- UI API called on a background thread
- xcode disable a button
- swift access appdelegate from viewcontroller
- change font swiftui
- swift increase int value
- IOS create UIAlertViewController programmatically
- xcode combine calayer into an image
- how to unwrap arrays with optional value in swift
- how do i get a string from a float swift to 1 decimal swift
- swift constraint center vertically
- swift allow gesture recognizer over others
- swift doc comments
- playing a sound in swift
- how to remove subview siwft 5
- get address from latitude and longitude in swift
- how to know when text changed textfield swiftui