"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.)

Answered by mjmsmith in 735005022

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.

Accepted Answer

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.

11

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

Thanks a lot for this answer. Been troubleshooting this bug for almost a day now, can't believe it's 2024 and Apple hasn't fixed this bug or mentioned this configuration in the developer documentation.

"Failed to set up CloudKit integration" in TestFlight build
 
 
Q