簡體   English   中英

KeychainItemWrapper導致iOS發行版崩潰

[英]KeychainItemWrapper causes crash for Distribution iOS build

在我的iOS應用程序中,我使用Apple提供的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)];

您的問題出在您的訪問組中。 您正在使用[[NSBundle mainBundle] bundleIdentifier] 這不是有效的訪問組。 您的訪問組必須以您的AppID開頭。 您可以對此進行硬編碼(如在KeychainItemWrapper示例代碼中所做的那樣),也可以在運行時查詢它

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM