Get your Apple iOS (iPhone), iPadOS (iPad) and Mac Catalyst app Version and Build number programmatically.

Here is a small function that I have written that you can use in your iOS, iPadOS or macOS Catalyst app to get your app’s current version and build number and print it on screen whether will on the app’s about or support view.

Function: 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 is how to print the value: Copy the below code in 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

Leave a Reply

Your email address will not be published. Required fields are marked *