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.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

我会感谢任何提示。

4

1 回答 1

0

看起来您没有正确地对应用程序进行代码签名。该代码对权利没有影响。

确保包标识符正确且代码设计有效

于 2012-11-11T18:48:37.213 回答