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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
notnoop
  • 58,763
  • 21
  • 123
  • 144

5 Answers5

10

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

notnoop
  • 58,763
  • 21
  • 123
  • 144
8

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

Graham Miln
  • 2,724
  • 3
  • 33
  • 33
6

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

Ash
  • 61
  • 1
  • 1
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.

gorbster
  • 704
  • 5
  • 6
  • 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. – Shade Apr 05 '11 at 07:20
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

Chibi
  • 95
  • 1
  • 1
  • 7