在我的iOS应用程序中,我正在使用苹果公司提供的KeychainItemWrapper来保存我的应用程序的一些重要数据。
当我使用开发人员配置文件在移动设备上部署应用程序时,应用程序工作得很好,但当我通过使用“分发”配置文件创建分发版本来部署相同的应用程序时,应用程序崩溃。
我分析了设备日志,但找不到问题所在。它使"writeToKeyChain“方法崩溃。我不能找出为什么这种情况只发生在分发配置文件构建上。
你知道为什么会发生这种事吗?以前有没有人遇到过这个问题?
iOS : 9.3.1
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
CoreFoundation 0x1817fee38 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x180e63f80 objc_exception_throw + 56
2 CoreFoundation 0x1817fed08 +[NSException raise:format:arguments:] + 108
3 Foundation 0x182184124 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 112
4 MyApp 0x10017fe6c -[KeychainItemWrapper writeToKeychain] (KeychainItemWrapper.m:328)
5 MyApp 0x10017f1c4 -[KeychainItemWrapper setObject:forKey:] (KeychainItemWrapper.m:177)
6 MyApp 0x1000c61cc +[MyKeyChainWrappper fetchInfo:] (MyKeyChainWrappper.m:41)编辑:
KeychainItemWrapper初始化代码
KeychainItemWrapper* mykeyChain = [[KeychainItemWrapper alloc] initWithIdentifier:@"My_Identifier" accessGroup:[[NSBundle mainBundle] bundleIdentifier]];
[mykeyChain setObject:(__bridge id)(kSecAttrAccessibleWhenUnlocked) forKey:(__bridge id)(kSecAttrAccessible)];发布于 2016-05-15 00:22:41
您的问题出在访问组中。您正在使用[[NSBundle mainBundle] bundleIdentifier]。这不是有效的访问组。您的访问组必须以AppID开头。您可以对此进行硬编码(就像在KeychainItemWrapper示例代码中所做的那样),也可以使用query it at runtime。
https://stackoverflow.com/questions/37195468
复制相似问题