xcode 钥匙串 SecOSStatusWith 错误:[-34018]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28173565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:32:57  来源:igfitidea点击:

Keychain SecOSStatusWith error:[-34018]

iosiphonexcodekeychain

提问by Tom Kraina

I'm having issues with accessing Keychain on a device. This happens only when the app is launched from Xcode. If I launch the app by myself (by tapping on its icon) the Keychain works without any problems. No issues in simulator either.

我在访问设备上的钥匙串时遇到问题。仅当从 Xcode 启动应用程序时才会发生这种情况。如果我自己启动应用程序(通过点击它的图标),钥匙串可以正常工作。模拟器也没有问题。

Console output:

控制台输出:

Jan 27 14:33:24 iPhone MyApp[4305] <Error>:  SecOSStatusWith error:[-34018] The operation couldn't be completed. (OSStatus error -34018 - Remote error : The operation couldn't be completed. (OSStatus error -34018 - client has neither application-identifier nor keychain-access-groups entitlements))
Jan 27 14:33:24 iPhone securityd[77] <Error>:  securityd_xpc_dictionary_handler MyApp[4305] delete The operation couldn't be completed. (OSStatus error -34018 - client has neither application-identifier nor keychain-access-groups entitlements)

I'm using Xcode 6.1.1 and iPhone 5 with iOS 8.1.1.

我在 iOS 8.1.1 上使用 Xcode 6.1.1 和 iPhone 5。

It's worth noting that the app I'm trying to debug has the code for accessing keychain as located in a Cocoa Touch frameworktarget (This could be the source of the problem).

值得注意的是,我正在尝试调试的应用程序具有用于访问位于Cocoa Touch 框架目标中的钥匙串的代码(这可能是问题的根源)。

The provisioning profile is a generic one: iOSTeam Provisioning Profile: *(Managed by Xcode)

配置文件是一个通用配置文件:(iOSTeam Provisioning Profile: *由 Xcode 管理)

回答by HeTzi

Try disabling all breakpoints when launching the appfrom Xcode. You can enable them afterwards.

从 Xcode启动应用程序时尝试禁用所有断点。您可以在之后启用它们。

回答by bllakjakk

There are 2 ways you can resolve this issue.

两种方法可以解决此问题

  1. Add entitlement file to your project. enter image description here

  2. Forcefully add folder code signing to your target through code signing.

  1. 将权利文件添加到您的项目。 在此处输入图片说明

  2. 通过代码签名将文件夹代码签名强制添加到您的目标。

codesign --verify --force --sign "$CODE_SIGN_IDENTITY""$CODESIGNING_FOLDER_PATH"

codesign --verify --force --sign "$CODE_SIGN_IDENTITY""$CODESIGNING_FOLDER_PATH"

enter image description here

在此处输入图片说明

回答by hstdt

Xcode 8 bug may also lead this.

Xcode 8 错误也可能导致此问题。

Github issue: KeychainAccess issue

Github 问题:KeychainAccess 问题

回答by Alex Nauda

In the Build Phases of your Target add a Run Script containing:

在目标的构建阶段中添加一个运行脚本,其中包含:

codesign --verify --force --sign "$CODE_SIGN_IDENTITY" "$CODESIGNING_FOLDER_PATH"

Example: adding a Run Script

例子: 添加运行脚本

I'm not sure why this should be required, but it worked for me to overcome a very similar error.

我不确定为什么需要这样做,但它对我来说克服了一个非常相似的错误。