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
func getVersion() -> String { | |
// if this doesn't unwrap, something is really wrong | |
guard let dictionary = Bundle.main.infoDictionary else { | |
preconditionFailure("Error: main bundle not found!") | |
} | |
let version = dictionary["CFBundleShortVersionString"] ?? "error" | |
#if DEBUG // Get build number, if you want it. Cleaner to leave out of release version. | |
let build = dictionary["CFBundleVersion"] ?? "error" | |
// the version+build format is recommended by https://semver.org | |
let versionBuild = "\(version)+\(build)" |
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
- (NSString *)getVersion { | |
NSDictionary *dictionary = [[NSBundle mainBundle] infoDictionary]; | |
NSString *version = dictionary[@"CFBundleShortVersionString"]; | |
#ifdef DEBUG // Get build number, if you want it. Cleaner to leave out of release version. | |
NSString *build = dictionary[@"CFBundleVersion"]; | |
// the version+build format is recommended by https://semver.org | |
NSString *versionBuild = [NSString stringWithFormat:@"%@+%@", version, build]; | |
return versionBuild; | |
#else | |
return version; |