Is Core Data hosted in CloudKit working in Xcode 13?

Hi, I'm pretty new to SwiftUI. I created a project in Xcode 12 using CoreData and Hosted in CloudKit. This auto-generated some code which (mostly) works (the template did not display the add or edit buttons in iOS / iPadOS since it lacks a navigation view [I know it is just an example view to get started, but I was surprised by this] and is also missing a mergePolicy and automaticallyMergesChangesFromParent to see results in a timely fashion [well around 15 seconds or so])... anyway... I got that figured out and it works well in the iOS / iPadOS simulators in Xcode 12 plus when run on my iPod touch and iPad Pro with the same version OS.

I just tried opening the project in Xcode 13 Beta and the iOS / iPadOS simulators to look around and right away, the syncing with iCloud isn't working. Is there something new required? Xcode 13 isn't showing any warnings or cautions with the code. Is this just a bug in the current beta that needs to be fixed? I'm also curious, is there a way to use the new concurrency in SwiftUI with the syncing between Core Data and iCloud if I wanted to check if something already exists in iCloud after it is done syncing before automatically generating some new data?

I'm attaching the errors reported in Xcode 13 Beta as the simulator ran the project:

Answered by mwcs01 in 682098022

I was able to get it to work today after updating to beta 3 versions. I did have to do a erase all contents and settings on the simulator and once that was done data from CloudKit came into my app.

Exact same issue here.

Looking at the logs, it appears the issue might be related to <CKError 0x60000015a400: "Internal Error" (1/5000); "Failed to sync user keys"> as almost every line with an error has that message.

Edit: I meant to comment instead of answer.

I talked with Apple about this during a lab session at WWDC21. They had me create a feedback ticket.

Here is the Feedback: FB9156589

Im having exactly the same problem. So far no resolution. Definitely seems to be the beta, as I've build the "CoreData + CloudKit" boilerplate app in Xcode 12.x which works, and then built the same with Xcode 13 which breaks.

Did you also notice that when you go back to Xcode 12.x, the old "minimise to refresh" trick doesn't work anymore? You have to close the app and restart it for the iCloud data to get pulled.

It seems to work on the device but not on the simulator.

Has anyone been able to get this to work in Beta 2? Still looks broken to me...

Accepted Answer

I was able to get it to work today after updating to beta 3 versions. I did have to do a erase all contents and settings on the simulator and once that was done data from CloudKit came into my app.

I just tried it out here. Thanks for the info about erasing all contents and settings in the simulator (I would not have thought to try that). It is now working after doing so.

Seems like a new issue in Beta 4 resulting in this error:

"Account Temporarily Unavailable" (1028/2011); "Account temporarily unavailable due to bad or missing auth token"

'Reset All Contents & Settings' on the simulator doesn't appear to fix it this time.

I've also noticed that the current App Store release version of my App which uses NSPersistentCloudKitContainer does not sync properly and crashes after 30 seconds. Nothing has changed other than installing Beta 4. I've submitted a bug report to Apple.

My CloudKit enabled macOS apps are suffering from exact the same error message when running macOS 12 beta 4. This happens on 2 different Macs running the same beta. As if developing for Apple is not already challenging enough.

Fixed for me on iOS 15 Beta 5, out today.

Is Core Data hosted in CloudKit working in Xcode 13?
 
 
Q