How can I programmatically get the value of the target version
, like in the image below?
As seen in the Properties window of the target of my Xcode proj
You don't need to change anything in your project or Xcode. Here's the Swift version for both separately:
let versionNumber = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as! String
let buildNumber = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleVersion") as! String
It's included in this repo, check it out:
https://github.com/goktugyil/EZSwiftExtensions