swiftxcodexcode8cloudkitosx-gatekeeper

Xcode successfully builds but fails to run macOS app


I've written a mac application that uses CloudKit, and ever since I've upgraded to Sierra and XCode 8, the app will successfully build, but Xcode will not launch the application when I click "run".

If I go into the Derived Data folder and manually double-click my application to launch it, it crashes immediately and displays the following in the error report:

Time Awake Since Boot: 12000 seconds
Time Since Wake:       6500 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_CRASH (Code Signature Invalid)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace CODESIGNING, Code 0x1

What's interesting is, if I archive the app and export a Developer ID-signed application, the exported build is signed successfully and works perfectly.

Additionally, If I go into the capabilities tab and toggle off the iCloud capability, the app successfully runs in XCode.

Whenever I run spctl on the app in the DerivedData folder, whether or not I have iCloud enabled or disabled, I always get this:

spctl --assess --verbose=4 MyApp.app
MyApp.app: rejected

In the General tab on XCode I've set it to "Automatically manage signing", and as far as I can tell, all of my certificates are valid.

Not really sure what to do here. I've even tried disabling Gatekeeper completely and still no luck.


Solution

  • Aaaargh. Found the answer to my problem, I hope the answer may help you as well. My code signing was set up correctly in the development target, but it was ad hoc signed in the Test Target. As soon as I set up a profile for the Test target the problem went away.

    enter image description here