EDIT
Updated for Swift 4.2
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
EDIT
As pointed out by @azdev on the new version of Xcode you will get a compile error for trying my previous solution, to solve this just edit it as suggested to unwrap the bundle dictionary using a !
let nsObject: AnyObject? = Bundle.main.infoDictionary!["CFBundleShortVersionString"]
End Edit
Just use the same logic than in Objective-C but with some small changes
//First get the nsObject by defining as an optional anyObject
let nsObject: AnyObject? = NSBundle.mainBundle().infoDictionary["CFBundleShortVersionString"]
//Then just cast the object as a String, but be careful, you may want to double check for nil
let version = nsObject as! String
I hope this helps you out.
David
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…