Created
April 27, 2017 00:16
-
-
Save wvdk/6d4478d1d975068a011eb0bc7d3c5c6f to your computer and use it in GitHub Desktop.
Get the version number from info plist and return nicely formatted
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
var prettyVersionNumber: String { | |
get { | |
if let infoDictionary = Bundle.main.infoDictionary { | |
if let versionNumber = infoDictionary["CFBundleShortVersionString"] as? String, | |
let buildNumber = infoDictionary["CFBundleVersion"] as? String { | |
return "\(versionNumber) (\(buildNumber))" | |
} | |
} | |
return "No version number found." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moved to https://github.com/wvdk/A-Swift-Vocabulary/blob/master/prettyVersionNumber.swift