问题描述
我遇到一些KeyChain代码问题导致通过 xcodebuild
创建的档案在作为ad-hoc应用程序分发并在设备上运行时崩溃。该问题不会影响通过Xcode创建的构建 - 只有通过命令行创建的构建。
I'm having a problem with some KeyChain code causing archives created via xcodebuild
to crash when distributed as ad-hoc apps and run on a device. The problem does not affect builds created via Xcode -- only those created via command line.
抛出错误的代码:(我正在使用KeyChain库找到)
The code that is throwing the error: (I'm using a KeyChain library found here)
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
权利文件:
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
</array>
xcodebuild
输出似乎正在处理授权文件:
The xcodebuild
output appears to be handling the entitlement file:
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
代码在模拟器,调试设备和ad-hoc发行版中无错误地运行。唯一的问题是通过命令行构建发生的。我缺少什么?
The code functions without error in Simulator, on a debug device and as an ad-hoc distribution. The only issue occurs via command line builds. What am I missing?
推荐答案
经过长时间的工作,我找到了解决这个问题的方法并修改了floatsign.sh脚本()
相应 - 权利必须像@sglist那样更新。您可以在此处找到实施方案:
After long work, i've found a solution to this issue and modified the floatsign.sh script (https://gist.github.com/mediabounds/1367348)accordingly - the entitlements have to be update like @sglist said. You can find the implementation here: https://gist.github.com/Weptun/5406993
这篇关于KeyChain集成导致崩溃,“缺少权利”错误 - 通过命令行构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!