Created
September 7, 2018 00:36
-
-
Save mannd/e5a17d6f89a6baa68d610d90bd2f198e to your computer and use it in GitHub Desktop.
get iOS version string using objective C
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; | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment