Is there a way to programmatically detect iOS version's build number, For example iOS version 9.0.2(13A452). I know how to detect iOS version eg: 9.0.2.
Is there any API to detect 13A452?
Thanks in advance.
Is there a way to programmatically detect iOS version's build number, For example iOS version 9.0.2(13A452). I know how to detect iOS version eg: 9.0.2.
Is there any API to detect 13A452?
Thanks in advance.
Figured I'd put the code up incase anyone needs it (works at run time), since it's slightly tricky to process!
MAKE SURE YOU #include <sys/sysctl.h>
//make sure you `#include <sys/sysctl.h>`
NSString *ctlKey = @"kern.osversion";
BOOL buildValueFound;
NSString *buildValue;
size_t size = 0;
if (sysctlbyname([ctlKey UTF8String], NULL, &size, NULL, 0) == -1) {
buildValueFound = NO;
} else {
char *machine = calloc( 1, size );
sysctlbyname([ctlKey UTF8String], machine, &size, NULL, 0);
NSString *ctlValue = [NSString stringWithCString:machine encoding:[NSString defaultCStringEncoding]];
free(machine);
buildValue = ctlValue;
buildValueFound = YES;
}
if (buildValueFound) {
NSLog(@"%@", buildValue);
} else {
NSLog(@"No build value found");
}
I have figured this out. Using KERN_OSVERSION on function sysctl returns iOS build number.