Code signing error CSSMERR_DL_MISSING_VALUE

Just been hit by this mysterious Xcode code-signing error when building an iPhone OS app for the device for the second time in a few weeks. The annoying thing is I forgot what caused it the first time so it wasted a few minutes again whilst I remembered the solution. So here for posterity is the cause.

I have a USB security key for use when logging in to Virtual Private Networks. The key serves my security certificate to the login process which is very convenient. However when I try to code sign with Xcode it seems that instead of going to the OSX keychain it tries to find my iPhone developer certificate on the USB key which is never going to work.

The simple solution is to remember to take the USB key out when I am finished with it. Now if I can only remember that the next time it happens…