Here is a small function I have written that you can use in your iOS, iPadOS or macOS Catalyst app to get your app’s current version, build number, and print it on the screen whether it will be on the app’s about or support view.
Copy the below function in the Xcode project’s UIViewController Swift class file.
func appVersion() -> (version: String, build: String) {
return ("\(Bundle.main.infoDictionary!["CFBundleShortVersionString"] as? String ?? "")", "\(Bundle.main.infoDictionary!["CFBundleVersion"] as? String ?? "").")
}
Here’s how to print the value: Copy the code below into the same Swift file inside the ViewDidLoad function.
print("App Info: Your app version number is \(self.appVersion().version) and build number is \(self.appVersion().build)")
Thanks & Regards
Mandar Apte