Using a non-default keychain in Xcode
Asked Answered
W

5

12

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

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

Weiler answered 31/8, 2009 at 3:6 Comment(0)
W
10

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

Weiler answered 19/11, 2009 at 16:3 Comment(2)
I filed rdar://9273506 for this issue.Nettie
I agree, I spent days on it… the only way is to set the temp keychain as default for a while :/Poulos
V
7

The codesign tool requires an absolute path to 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

Vidrine answered 11/7, 2011 at 5:13 Comment(1)
A full path is only needed if the keychain is not in the default ~/Library/Keychains pathLowbrow
F
6

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

Fini answered 16/8, 2010 at 15:37 Comment(0)
G
4

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.

Gatt answered 7/9, 2010 at 15:16 Comment(1)
Also, you can create a temporary keychain on the fly from command line, import your certificates/keys, set it as the default during compilation and code signing and then remove it, restoring your previous default keychain.Yardmaster
S
0

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:

security list-keychains

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

Stine answered 5/6, 2019 at 16:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.