Whenever I try to commit my files, I get this error message:

gpg: cannot open `/dev/tty': Device not configured
error: gpg failed to sign the data
fatal: failed to write commit object

Yikes! This is because I have GPG signatures enabled for git.

Is it possible to use GPG signatures with Xcode repositories?

It's not a huge deal, as it's easy enough to disable GPG signatures (git config commit.gpgsign true), but it's a rather nice identification to have.

  • I wonder if it's possible to add a GPG signature after making the commit.. then perhaps some kind of hook could be made to add signatures after committing from Xcode? – Florrie Sep 6 '16 at 14:05

The issue here is that the default pinentry (password dialog) is terminal-based, and when you are in Xcode, Git isn't invoked with a terminal attached. Consequently, there's no way for GnuPG to prompt you for a passphrase.

The easiest way to handle this is to install the Mac pinentry with brew install pinentry-mac. You can then update your ~/.gnupg/gpg-agent.conf with pinentry-program /usr/local/bin/pinentry-mac. You may need to kill off any running gpg-agent processes so that they'll pick up the new configuration.

A rather thorough set of documentation on how to do this is available in a GitHub Gist.


Is it possible to use GPG signatures with Xcode repositories?

No, Xcode doesn't support this.

But, an "Xcode repository" is just a normal git repository. If you really want to use GPG signing, do all of your commits, merges, etc from the command prompt.

  • 1
    Also worth pointing out that GPG signing will work within Xcode for awhile after the previous signed commit was made (from the terminal), since no password will be necessary for awhile afterwards. – William T Froggard Jun 3 '18 at 7:31

Your Answer

