Created
April 21, 2015 08:46
-
-
Save juliengdt/6f0fad9b3f3bb02f166f to your computer and use it in GitHub Desktop.
[SWIFT] App Version & Build Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIApplication { | |
class func appVersion() -> String { | |
return NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as! String | |
} | |
class func appBuild() -> String { | |
return NSBundle.mainBundle().objectForInfoDictionaryKey(kCFBundleVersionKey as String) as! String | |
} | |
class func versionBuild() -> String { | |
let version = appVersion(), build = appBuild() | |
return version == build ? "v\(version)" : "v\(version)(\(build))" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment