使用codesign -d --entitlements - app的路径 我们可以看到.ipa的代码签名权利。
例如,来自AppStore的Instagram应用程序。
</array>
<key>application-identifier</key>
<string>MH9GU9K5PX.com.burbn.instagram</string>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>777W53UFB2.com.burbn.instagram</string>
<key>com.apple.developer.team-identifier</key>
<string>777W53UFB2</string>
<key>aps-environment</key>
<string>production</string>
<key>com.apple.developer.icloud-container-environment</key>
<string>Production</string>
<key>com.apple.developer.associated-domains</key>
<array>
有没有办法在运行时检索com.apple.developer.team-identifier?
使用此代码段
+ (NSString *)bundleSeedID {
NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys:
(__bridge NSString *)kSecClassGenericPassword, (__bridge NSString *)kSecClass,
@"bundleSeedID", 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);
return bundleSeedID;
}
我们将获得应用程序前缀ID(有时应用程序前缀ID可能与团队ID不同。
如何在我的应用程序中访问com.apple.developer.team-identifier?
此信息以embedded.mobileprovision
的形式存储在应用程序中,这意味着您可以阅读它并提取所需内容。它主要是plist数据,其中包含一些额外的数据。删除额外数据后,您可以像plist一样对其进行解码。
这个网站有更多的细节和良好的示例代码:https://blog.process-one.net/reading-ios-provisioning-profile-in-swift/