Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

Is there a way in objective-C to set version and build number the way we do it for iOS apps (EX: Version: 2.5.1 Build: 2.5.1.12) ?

Also need a way to detect this version number so i can expose an API 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;

Which returns the SDK version and build number.

Using: Xcode - 7.0 (Beta 3 version)

Thanks in advance.

like image 262
Ankit Jain Avatar asked Oct 20 '22 06:10

Ankit Jain


1 Answers

You can set version and build number clicking in the Project(left side) -> General tab(right side) -> Identity section. You will find the fields: Bundle Identifier, Version and Build.

For get the values programmatically:

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

NSString *version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
NSString *build = [infoDictionary objectForKey:kCFBundleVersionKey];
like image 67
Wesley Galindo Avatar answered Nov 15 '22 03:11

Wesley Galindo