在 Xcode 中使用非默认钥匙串

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1355637/
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-14 18:46:38  来源:igfitidea点击:

Using a non-default keychain in Xcode

iphonexcodekeychaincodesign

提问by notnoop

How can I use a non-default keychain in Xcode iPhone project.

如何在 Xcode iPhone 项目中使用非默认钥匙串。

I have already tried '--keychain mycerts.keychain' in 'Other Code Signing Flags' in 'Code signing' build settings.

我已经在“代码签名”构建设置的“其他代码签名标志”中尝试过“--keychain mycerts.keychain”。

采纳答案by notnoop

After a long time of research, I concluded that it cannot be done.

经过长时间的研究,我得出结论,这是不可能的。

回答by Ash

in the Build setting under Code Signing -> Other code signing Flags, create a flag "--keychain keychain-name.keychain"

在代码签名 -> 其他代码签名标志下的构建设置中,创建一个标志“--keychain keychain-name.keychain”

回答by Graham Miln

The codesign tool requires an absolute pathto the keychain.

协同设计工具需要钥匙串的绝对路径

Use an additional "Run Script Build Phase" to call the codesign tool with the custom keychain. The embedded script should look like:

使用额外的“运行脚本构建阶段”来调用带有自定义钥匙串的协同设计工具。嵌入式脚本应如下所示:

codesign -s 'your-identity' --keychain "${SRCROOT}/path/to/keychain" "${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

enter image description here

在此处输入图片说明

回答by gorbster

While inconvenient, you can temporarily change your "default Keychain" to whichever keychain has your certificate/keys. XCode will then search that keychain during code-signing. You can do this via Keychain Access.app or the security(1) command-line utility. You're responsible for unlocking said keychain yourself, however.

虽然不方便,但您可以暂时将“默认钥匙串”更改为具有您的证书/密钥的任何钥匙串。XCode 将在代码签名期间搜索该钥匙串。您可以通过 Keychain Access.app 或 security(1) 命令行实用程序执行此操作。但是,您有责任自己解锁所述钥匙串。

回答by Chibi

This problem can be solved by setting the keychain search list to include your keychain:

这个问题可以通过设置钥匙串搜索列表来解决你的钥匙串:

security list-keychains -s login.keychain mycerts.keychain etc.keychain

To view the active keychain search list, use the same command without the -s param:

要查看活动钥匙串搜索列表,请使用不带 -s 参数的相同命令:

security list-keychains

A great link for reference is here: https://ss64.com/osx/security-keychain.html

一个很好的参考链接在这里:https: //ss64.com/osx/security-keychain.html