Skip to content

Instantly share code, notes, and snippets.

@mannd
Created September 7, 2018 00:36
Show Gist options
  • Save mannd/e5a17d6f89a6baa68d610d90bd2f198e to your computer and use it in GitHub Desktop.
Save mannd/e5a17d6f89a6baa68d610d90bd2f198e to your computer and use it in GitHub Desktop.
get iOS version string using objective C
- (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