如何以编程方式访问 Bundle Seed ID/Team ID/App Identifier Prefix 字符串? (据我所知,这些都是一回事)。
我正在使用 UICKeychainStore 钥匙串(keychain)包装器来跨多个应用程序保存数据。这些应用程序中的每一个在其授权列表中都有一个共享的钥匙串(keychain)访问组,并共享相同的配置文件。默认情况下,钥匙串(keychain)服务使用 plist 中的第一个访问组作为保存数据的访问组。当我调试 UICKeychainStore 时,这看起来像“AS234SDG.com.myCompany.SpecificApp”。我想将访问组设置为“AS234SDG.com.myCompany.SharedStuff”,但我似乎无法找到如何以编程方式获取访问组的“AS234SDG”字符串,并希望避免对其进行硬编码如果可能的话。
最佳答案
Info.plist 可以有你自己的信息,如果你用 $(AppIdentifierPrefix)
写一个值,它会在构建阶段被替换为真正的应用程序标识符前缀。
那么,试试这个:
在您的 Info.plist 中,添加有关应用标识符前缀的信息。
<key>AppIdentifierPrefix</key>
<string>$(AppIdentifierPrefix)</string>
然后您可以使用 Objective-C 以编程方式检索它:
NSString *appIdentifierPrefix =
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppIdentifierPrefix"];
和 swift :
let appIdentifierPrefix =
Bundle.main.infoDictionary!["AppIdentifierPrefix"] as! String
请注意,appIdentifierPrefix
以句点结尾;例如AS234SDG。
关于iphone - 以编程方式访问应用标识符前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40506401/