Search code examples
iosxcodecode-signing

Xcode code signing not working after force quit


I have been actively developing with Xcode for over 5 years, so first off, I have to say this is not a typical problem with Xcode's code signing. It is most likely because the Mac was almost frozen and I did a force quit of Xcode. Subsequently, code signing is failing for all my Xcode projects, even those that were not open during the force quit of Xcode 10.

[the error in Xcode]

the error in Xcode

[Xcode debug log]

the view in the Xcode debug log

Verified with Keychain Access that the certificates are actually fine, not expired, etc.

Things I attempted which failed to resolve the problem:

  • uncheck and check "automatic signing"
  • generated a new developer certificate, valid till 18 Oct 2019 (which keychain access recognizes as such)
  • clear Derived Data for the app and modules cache
  • clean build folder
  • quit and restart Xcode
  • cleared Xcode caches with rm -r ~/Library/Caches/com.apple.dt.Xcode
  • reset Xcode defaults with defaults delete com.apple.dt.Xcode
  • uninstall and reinstall Xcode 10
  • installed Xcode 9.4.1, tried to set the "Command Line Tools" to Xcode 9.4.1 and Xcode 10, both had the same problem

Since it didn't work with both Xcode 9.4.1 and Xcode 10 (even Xcode 9.4.1 with command line tools of Xcode 9.4.1), plus keychain access shows the certs I fine, I wonder if Xcode is using something else on the Mac, outside of Xcode itself, in the cert signing process, in a location that got corrupted by the "force quit" of Xcode? I wouldn't mind reinstalling something, or deleting some other cache, if I knew what to reinstall or delete.

Update: when I switched user accounts on the same Mac, code signing in Xcode was ok! (I exported a developer key from the original account, emailed it to myself, got it in the keychain for the second account, and then used it for the code signing). Indeed, the certificates are ok, so that narrows down the search, still going through the suggestions ..


Solution

  • This is highly embarrassing, but in the hope of helping anyone who encounters a similar problem in the future, here's the simple solution that worked.

    I rebooted the machine.

    Now code signing is working fine in both the projects I had opened at the time of the force quit and those that were not opened at that time.

    Actually, I did try rebooting earlier on, so it may be the combination of one of the steps tried, plus the later rebooting, which did the trick. Problem is I didn't reboot after every step, so am not sure which step it was.