Last active
June 10, 2020 20:58
-
-
Save alexpaul/de85efd8710053a1b6c96f46491ef904 to your computer and use it in GitHub Desktop.
Get the version and build number for your app. This is especially useful to track version / builds on the AppStore / TestFlight.
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
| import Foundation | |
| class ApplicationInfo { | |
| class func getVersionBuildNumber() -> String { | |
| guard let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString"), | |
| let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") | |
| else { | |
| fatalError("no version info") | |
| } | |
| return "\(version) (\(build))" | |
| } | |
| class func getAppName() -> String { | |
| guard let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String else { | |
| fatalError("what? no app name") | |
| } | |
| return appName | |
| } | |
| } | |
| /* | |
| If you're missing this CFBundleDisplayName add the following to the Info.plist | |
| <key>CFBundleDisplayName</key> | |
| <string>CareerView</string> | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment