0

I followed the documentation for adding CloudKit to my existing project as described at Setting Up Core Data with CloudKit. After running the project on two different simulators I noticed that it was not syncing. This led down a rabbit trail of tutorials which all showed the same steps that I had already completed (add iCloud and Background Modes capabilities and switch NSPersistentContainer to NSPersistentCloudKitContainer).

Core Data+CloudKit not connecting to CloudKit seemed to have the same concern, but following the suggestions there did not help either.

// In my AppDelegate
lazy var persistentContainer: NSPersistentCloudKitContainer = {
    let container = NSPersistentCloudKitContainer(name: "CloudTest")
    container.loadPersistentStores(completionHandler: { (storeDescription, error) in
        if let error = error as NSError? {
            fatalError("Unresolved error \(error), \(error.userInfo)")
        }
    })
    container.viewContext.automaticallyMergesChangesFromParent = true
//        container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
    return container
}()

All of my local saving and retrieving is working as it did before. In the iCloud Dashboard no data is showing and telemetry is blank as well. Is there something simple that I am missing?

Medicine Man
  • 81
  • 2
  • 10
  • Did you find a solution for that problem? I have (nearly) the same problem. Syncing on two different macOS computers is a catastrophy. Data isn‘t uploaded to icloud or gets lost somewhere between both machines. Both computers have the same apple id logged in, but no chance! Read tons of hints and supposed solutions. None of them work or are totally outdated. – mihema Apr 02 '23 at 02:16
  • Simulating user on cloudkit console, I could find out, that my changed data aren‘t uploaded to iCloud. – mihema Apr 02 '23 at 02:30

0 Answers0