Created
June 12, 2019 17:51
-
-
Save rsaenzi/4f4c346d4b5f2b23611b862628cacdc2 to your computer and use it in GitHub Desktop.
Functions to get the version and build numbers in an iOS app
This file contains hidden or 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
| // | |
| // UIApplication+AppVersion.swift | |
| // | |
| // Created by Rigoberto Sáenz Imbacuán (https://www.linkedin.com/in/rsaenzi/) | |
| // Copyright © 2019. All rights reserved. | |
| // | |
| import UIKit | |
| 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() | |
| let 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