I would like to be able to get the current version of my iOS project/app as an NSString
object without having to define a constant in a file somewhere. I don\'t
In Swift, you can get bundle version by using:
let info:NSDictionary = NSBundle.mainBundle().infoDictionary!
let version:String = info.objectForKey("CFBundleShortVersionString") as! String
versionLabel.text = "Version:" + version
So heres a Swift version for both of these separately:
let versionNumber = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as! String
let buildNumber = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleVersion") as! String
Its included in this repo, check it out:
https://github.com/goktugyil/EZSwiftExtensions