如何在运行时以编程方式从codesign entitlements中检索com.apple.developer.team-identifier?

4

使用codesign -d --entitlements - 应用路径
我们可以查看.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?
1个回答

0

这些信息存储在应用程序中,以embedded.mobileprovision的形式存在,这意味着您可以读取它并提取所需内容。它主要是plist数据,周围包裹了一些额外的数据。一旦去除了额外的数据,您就可以像解码plist一样对其进行解码。

此网站有更多详细信息和良好的示例代码:https://blog.process-one.net/reading-ios-provisioning-profile-in-swift/


1
但是在将.ipa提交到AppStore后,embedded.mobileprovision会被删除。在开发过程中 - 没问题。 - Andrei Mistetskii

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接