2
我編寫了一個應用程序,它使用KeychainItemWrapper類將用戶憑證保存在iOS鑰匙串中。 所有的工作都很好,但如果應用程序因企業使用而辭職,則保存憑證不再有效。辭職後無法在鑰匙串中保存憑證
我收到以下錯誤,但應用不崩潰:
SecItemCopyMatching: missing entitlement
securityd[2314] <Error>: Directory[2312] SecItemCopyMatching: missing entitlement
securityd[2314] <Error>: Directory[2312] SecItemAdd: missing entitlement
securityd[2314] <Error>: Directory[2312] SecItemCopyMatching: missing entitlement
securityd[2314] <Error>: XYZ[2312] SecItemAdd: missing entitlement
我發起類如下:
KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"MYAPP_credentials" accessGroup:nil];
[keychain setObject:userName forKey:(__bridge id)kSecAttrAccount];
[keychain setObject:password forKey:(__bridge id)kSecValueData];
我也嘗試創建一個Entitlements.plist(使用的XCode 4.5 0.2)
和下面的代碼:
KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"p7s1_dictionary" accessGroup:@"net.XYZ.directory"];
[keychain setObject:userName forKey:(__bridge id)kSecAttrAccount];
[keychain setObject:password forKey:(__bridge id)kSecValueData];
雖然這樣做,我得到一個應用程序崩潰,出現以下消息:
Assertion failure in -[KeychainItemWrapper writeToKeychain], /Users/omid/Documents/Workspace/Xcode workspace/Directory/KeychainItemWrapper.m:305
2012-11-11 19:51:48.860 Directory[4162:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't add the Keychain Item.'
First throw call stack:
(0x32c7c2a3 0x33b3a97f 0x32c7c15d 0x348252af 0x32cbf 0x3230f 0x43aad 0x3488aef5 0x347ca9f1 0x347ca90d 0x39d9d5df 0x39d9cccb 0x39dc5133 0x32bc274d 0x39dc5593 0x39d2915d 0x32c51683 0x32c50ee9 0x32c4fcb7 0x32bc2ebd 0x32bc2d49 0x3a9c02eb 0x3a47e2f9 0x1ac69 0x1a140)
更新: 這是我用辭職
IPA="path to the .ipa file"
PROVISION="path to the .mobileprovision file"
CERTIFICATE="iPhone Distribution: a name"
export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"
unzip -q "$IPA"
rm -rf Payload/*.app/_CodeSignature Payload/*.app/CodeResources
cp "$PROVISION" Payload/*.app/embedded.mobileprovision
/usr/bin/codesign -f -s "$CERTIFICATE" --resource-rules Payload/*.app/ResourceRules.plist Payload/*.app
zip -qr resigned.ipa Payload
rm -rf Payload
劇本我會很感激任何提示。
看起來你沒有正確代碼簽名的應用程序 –