23

For some reason, whenever I try to codesign in xcode, I am getting this error

(path to app): The operation was cancelled by the user. Command /usr/bin/codesign failed with exit code 1

Bob Bobbio
  • 577
  • 2
  • 5
  • 10

3 Answers3

49

I had this error after I changed my login keychain password, and my developer certificate was in this keychain.

I restarted and unlocked the keychain again and all was well.

freespace
  • 16,529
  • 4
  • 36
  • 58
  • 16
    Restart didn't fix it, but locking and unlocking the keychain did. Weird. Thanks. – Mike Akers Dec 17 '11 at 23:56
  • 1
    I changed my password but never rebooted, always just closed lid to sleep. When I tried unlocking my keychain it gave some error message about not having access. After reboot, keychain then accepted my new password. – drfence Jun 12 '12 at 04:55
  • One more clarification - XCode was working fine ( prior to reboot ) up until I tried to access my keychain. My new password didn't work until I rebooted. Trying to access the keychain before reboot caused XCode to start failing. – drfence Jun 12 '12 at 15:29
  • Wow.. this fixed it. xCode really makes me consider quitting this programming thing. I had changed my login pw, login keychain was unlocked and getting this error. Locked and unlocked keychain, error gone. Wow. – Bobby Oct 09 '12 at 14:09
  • Still happens in 2016, and this fixed it for me. Thanks ! – nha Feb 04 '16 at 13:54
  • That fixed my issue. Thanks :) – W.S Mar 29 '16 at 12:14
  • 1
    Tons of thanks for this tip. In my case, it wasn't used Xcode playing up (and by coincidence, just after I upgraded to Xcode 8.1), but also mail asking me for all kinds of passwords and generally being very unhappy even when I supplied them. – gnasher729 Oct 31 '16 at 13:07
  • I got an error that said: unknown error -1=ffffffffffffffff Command /usr/bin/codesign failed with exit code 1. I didn't change my keychain password or upgrade any software to cause this error, and the error prevented me from building and running to my device until I locked and unlocked my keychain like this answer mentioned. This happened to me in Xcode 9.2. The only thing that might be remotely strange is that I plugged in a relative's iPhone just to charge it, and disallowed iTunes from managing it. – James C Dec 16 '17 at 22:17
  • I found that using the "Lock All Keychains" option from the Keychain Access application's main menu, and then unlocking the keychain by clicking the padlock icon (top left corner of the Keychain Access app window) and entering my account password was indeed part of the solution. I also found it was necessary to exit out of Xcode, and then re-open Xcode. After that the error went away! As a note, I had not recently changed by account password, so the root cause seems a little different, but the symptoms were the same, and the solution here solved the problem. – bluebinary Apr 26 '18 at 20:51
20

I spent hours trying to figure out why I was getting "The operation was cancelled by the user. Command /usr/bin/codesign failed with exit code 1".

I tried locking and unlocking all my keys (be sure you know the password first) and it fixed the problem.

Thanks to the contributors above for this advice.

Perry Power
  • 201
  • 2
  • 2
7

For some reason, I restarted my computer and the error went away.

Bob Bobbio
  • 577
  • 2
  • 5
  • 10
  • Same here. Got OS X Server installed on the Mac I am developing, I suspect that restarting my Mac did a clean restart of OS X Server to. – Blackus Jul 30 '15 at 08:08