Skip to content

Instantly share code, notes, and snippets.

@ashleymills
Last active April 27, 2022 14:49
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ashleymills/6ec9fce6d7ec2a11af9b to your computer and use it in GitHub Desktop.
Save ashleymills/6ec9fce6d7ec2a11af9b to your computer and use it in GitHub Desktop.
UIApplication extension to get app version / build
extension UIApplication {
class func appVersion() -> String {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
}
class func appBuild() -> String {
return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
}
class func versionBuild() -> String {
let version = appVersion(), build = appBuild()
return version == build ? "v\(version)" : "v\(version)(\(build))"
}
}
@danielgomezrico
Copy link

Cool thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment