Testing macOS CloudKit App in Xcode

I am having a problem testing a macOS CloudKit app.


When I archive and export the app, it runs as expected against CloudKit with no errors. But when I try to run the app from Xcode it gets authentication errors.


From Xocde, when checking account status the app reports CKAccountStatus.noAccount, "The user’s iCloud account is not available because no account information has been provided for this device. (3)"


From Xcode, if I still try to write to the public database the app reports "Not Authenticated" (9/1002); "CloudKit access was denied by user settings"; Retry after 3.0 seconds.


Oddly enough, If I leave the archived and exported app running, then try to debug a 2nd version of the app from Xcode, the 2nd debug version seems to work.


Is it possible to reliabily debug a macOS CloudKit app from Xcode? If so, any ideas what might be wrong in my case?


Environment:

High Sierra

Xcode Version 10.0 (10A254a)

Automatic code signing

Automatic provisioning

Deplyment target 10.13

Replies

Works fine for me running an app directly from Xcode. To ask the obvious, you're signing into iCloud on your Mac?

Yes, the mac is signed in to iCloud. Hence when I run the app using archive and export (outside of xcode), it runs just fine. Same machine and same build (Archive build is set to Debug, as is Run build).


The iCloud credentials are for a paid developer. The cloud containers are set for development containers.