Getting iOS app version programmatically

Getting the version string and the build number, in Objective-C, Swift, and C# (Xamarin)

Use CFBundleVersion for the build number instead of the string.


let versionStr = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
let versionNum = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "" // Yes, the version number is also a String
let version = String(format: "%@-%@", versionStr, versionNum)


let nsObject: AnyObject? = NSBundle.mainBundle().infoDictionary["CFBundleShortVersionString"]
let version = nsObject as String


NSObject ver = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"];