Is there's a way to get the product version number inside swift code, like
println("Running version \($PRODUCT_VERSION)")
I have to define some standartUserDefaults, that are bound to the Version and build number and i don't like to put them into my code when it's there at build time.
NSProcessInfo don't have the build number. Any suggestions for me?
To compare app version strings, you can use compare(_:options:range:) with an option of . numeric . For brevity, I will create a String extension to wrap compare(_:options:range:) and call it versionCompare(_:) .
Generally Version and the build numbers work together to uniquely identify a particular App Store submission for an app. For each new version of your app, you will provide a version number to differentiate it from previous versions. The version number works like a name for each release of your app.
In Swift 5.3:
extension UIApplication {
static var appVersion: String? {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
}
}
Usage:
UIApplication.appVersion!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With