How to set version number for SDK in iOS / Objective C?

I am writing an iOS SDK using the Objective-C programming language. I would like to know if there is a field in Xcode where I can set the version number for the SDK

Is there a way from objective-C to install the version and build the number , as we do for iOS applications (EX: Version: 2.5.1 Build: 2.5.1.12)?

I also need a way to detect this version number, so I can set the API to be something like

- (NSString *)getSDKVersion {
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *majorVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    NSString *minorVersion = [infoDictionary objectForKey:@"CFBundleVersion"];

    return [NSString stringWithFormat:@"SDK Version %@ (%@)", majorVersion, minorVersion];
}

-(NSString*)getSDKBuildVersion;

Returns the SDK version and build number.

Usage: Xcode - 7.0 (Beta 3 Version)

Thanks in advance.

+4
source share
1 answer

, () β†’ () β†’ . : Bundle Identifier, Version Build.

:

NSDictionary *infoDictionary = [[NSBundle mainBundle]infoDictionary];

NSString *version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
NSString *build = [infoDictionary objectForKey:kCFBundleVersionKey];
+2

Source: https://habr.com/ru/post/1598881/


All Articles