0

Trying to create Private configuration in Core data and export it to Cl;oudKit private database with NSPersistentCloudKitContainer. As a first step, inside the core data model, created a new private configuration. Created a new entity which by default dets added to default configuration. Dragged the newly created entity from default configuration to the private configuration. It crashes. Am I doing this right? If so is it Xcode 13.3.1 bug ? and should I upgrade?

Once I get past this issue, I plan to load persistent stores to export/synchronize the new entity from core data private configuration to cloudkit private database, which will hopefully work.

container.loadPersistentStores(completionHandler: { (loadedStoreDescription, error) in
  if let loadError = error as NSError? {
    fatalError("###\(#function): Failed to load persistent stores:\(loadError)")
  } else if let cloudKitContainerOptions = loadedStoreDescription.cloudKitContainerOptions {
    if #available(iOS 14.0, *) {
      if .public == loadedStoreDescription.cloudKitContainerOptions?.databaseScope {
        self._publicPersistentStore = container.persistentStoreCoordinator.persistentStore(for: loadedStoreDescription.url!)
      } else if .private == loadedStoreDescription.cloudKitContainerOptions?.databaseScope {
        self._privatePersistentStore = container.persistentStoreCoordinator.persistentStore(for: loadedStoreDescription.url!)
      } 
    } else {
      // Fallback on earlier versions
    }
  }
    
vrao
  • 545
  • 2
  • 12
  • 33
  • If by "it crashes" you mean that Xcode crashes, then yes, it's a bug. Xcode crashing is always a bug in Xcode. If you mean your app crashes, you should provide more detail about the crash. – Tom Harrington Nov 15 '22 at 00:44
  • Xcode crashes. May be I need to upgrade. I am looking for code to synch and export Core data entity into CloudKit private database. Whatever I posted, I am not sure it is the right thing. I am looking for right solution – vrao Nov 15 '22 at 21:27
  • I upgraded xcode to 13.4.1. No crash. I know how to export all my Core data entities to public database on CloudKit . But I want to export some core data entities to private database on cloud Kit. I don't see any examples on the net. Can someone provide that? – vrao Nov 20 '22 at 05:13
  • I am waiting for an answer from someone – vrao Nov 22 '22 at 15:41

0 Answers0