Husein Behboodi Rad Husein Behboodi Rad - 24 days ago 6
iOS Question

What is Android keystore digest equaivalent in iOS apps

In Android application developers use a

keystore
to sign their applications. They can fetch the digest of the
keystore
by using some Android SDK's like
PackageManager
. The keystore digest is unique for same apps even after update.

Some third developers use this digest in their third APIs. For example it is using in Maps API of google.

Now I am wondered is there something like this in iOS. So that we can fetch it from iOS SDK and it be unique for all versions of my application?

Answer

Base on my researches we can use Team ID as an equivalent for identifying the signer of an app.

Team ID is a unique identifier associated to a development team in iTunes Connect and each app that is publishing with any kind of Apple accounts (including organization, individual or enterprise ) has these unique identifier.

Just we should notice that we have to read this from the iOS SDK not hardcoding it in the plist. I use below code:

CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);


NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys:
                       (__bridge NSString *)kSecClassGenericPassword,
                       (__bridge NSString *)kSecClass,
                       string, kSecAttrAccount,
                       @"", kSecAttrService,
                       (id)kCFBooleanTrue, kSecReturnAttributes,
                       nil];
CFDictionaryRef result = nil;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query,
                                      (CFTypeRef *)&result
                                      );
if (status == errSecItemNotFound)
    status = SecItemAdd((__bridge CFDictionaryRef)query, (CFTypeRef *)&result);
if (status != errSecSuccess)
    return nil;
NSString *accessGroup = [(__bridge NSDictionary *)result objectForKey:
                         (__bridge NSString *)kSecAttrAccessGroup
                         ];
NSArray *components = [accessGroup componentsSeparatedByString:@"."];
NSString *bundleSeedID = [[components objectEnumerator] nextObject];
CFRelease(result);

Finally the bundleSeedID contains the teamID of current app.