일부 KeyChain 코드에 문제가있어서 xcodebuild
을 통해 생성 된 보관 파일이 비정형 응용 프로그램으로 배포되고 장치에서 실행될 때 충돌합니다. 이 문제는 Xcode를 통해 생성 된 빌드에는 영향을 미치지 않으며 명령 행을 통해 생성 된 빌드에만 영향을줍니다."누락 된 자격 부여"오류로 인한 KeyChain 통합 오류 - 명령 줄 빌드를 통해
오류를 던지고 코드 :
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"myapp" accessGroup:nil];
NSString *testKeychain = (NSString *)[keychain objectForKey:(__bridge id) kSecAttrAccount];
if (testKeychain.length) {
NSLog(@"KeyChain value for kSecAttrAccount: %@", testKeychain);
} else {
NSLog(@"No KeyChain value for kSecAttrAccount");
}
[keychain setObject:@"Shared KeyChain value!" forKey:(__bridge id) kSecAttrAccount]; // <-- error thrown here
은 "실종 자격"오류 (들)
2012-06-15 10:03:20 AM +0000 securityd MyApp [138] SecItemCopyMatching: missing entitlement
2012-06-15 10:03:20 AM +0000 MyApp No KeyChain value for kSecAttrAccount
2012-06-15 10:03:20 AM +0000 securityd MyApp [138] SecItemCopyMatching: missing entitlement
2012-06-15 10:03:20 AM +0000 securityd MyApp [138] SecItemAdd: missing entitlement
2012-06-15 10:03:20 AM +0000 MyApp *** Assertion failure in -[KeychainItemWrapper writeToKeychain], /Users/davidbjames/XCode/.../KeychainItemWrapper.m:305
자격 파일 (나는 키 체인 라이브러리 here을 발견 사용하고 있습니다) :
를<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
</array>
xcodebuild
출력이 인 타이틀먼트 파일을 처리하는 것으로 보입니다.
setenv CODE_SIGN_ENTITLEMENTS MyApp/MyApp.entitlements
..
ProcessProductPackaging MyApp/MyApp.entitlements /etc/etc/build/MyApp.xcent
..
builtin-productPackagingUtility /etc/etc/MyApp.entitlements -entitlements -format xml -o /etc/etc/MyApp.xcent
코드는 Simulator, 디버그 장치 및 ad-hoc 배포에서 오류없이 작동합니다. 유일한 문제는 명령 줄 빌드를 통해 발생합니다. 내가 뭘 놓치고 있니?
이 질문을 한 이후로 많은 달이 지났으며 더 이상 영향을받는 응용 프로그램을 유지 관리하지 않습니다. "두껍게"있는 사람이 아래 답변 중 하나를 확인할 수 있으면 여기에 의견을 말하면 답을 표시합니다. 나는 @sglist 대답을 향한 경향이 있지만 다른 의견을 원합니다. 감사합니다 –