"Failed to set up CloudKit integration" in TestFlight build

I'm building a macOS + iOS SwiftUI app using Xcode 14.1b3 on a Mac running macOS 13.b11. The app uses Core Data + CloudKit.

With development builds, CloudKit integration works on the Mac app and the iOS app. Existing records are fetched from iCloud, and new records are uploaded to iCloud. Everybody's happy.

With TestFlight builds, the iOS app has no problems. But CloudKit integration isn't working in the Mac app at all. No existing records are fetched, no new records are uploaded.

In the Console, I see this message:

error: CoreData+CloudKit: Failed to set up CloudKit integration for store: <NSSQLCore: 0x1324079e0> (URL: <local file url>)

Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.cloudd was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.cloudd was invalidated: failed at lookup with error 159 - Sandbox restriction.}

I thought it might be that I was missing the com.apple.security.network.client entitlement, but adding that didn't help.

Any suggestions what I might be missing? (It's my first sandboxed Mac app, so it might be really obvious to anyone but me.)

Accepted Reply

In case anyone else runs into this, the fix is that CloudKit.framework has to be included in the app target's "Frameworks, Libraries, and Embedded Content" section.

  • Many thanks! I've been stuck on this same problem, with an app that had been syncing successfully under macOS 12.x, ever since upgrading to 13.0.

  • Thanks! Added it with "Do Not Embed" and it worked. How should we have known this?!

  • Thank you, this fix works for me!

Add a Comment

Replies

In case anyone else runs into this, the fix is that CloudKit.framework has to be included in the app target's "Frameworks, Libraries, and Embedded Content" section.

  • Many thanks! I've been stuck on this same problem, with an app that had been syncing successfully under macOS 12.x, ever since upgrading to 13.0.

  • Thanks! Added it with "Do Not Embed" and it worked. How should we have known this?!

  • Thank you, this fix works for me!

Add a Comment

Thanks a lot for this answer. Was stuck on this for more than 2 days.