I have a CoreData private database that I'd like to make into a public database. I've done this before but this database is more complicated and perhaps that is the underlying issue. When I check the CloudKit console logs all I see i a request flagged as BAD REQUEST. How can I tell why it is a bad request?
I am not getting any data synched to CloudKit.
My setup in PersistenceController is ...
import CoreData
import CloudKit
import UIKit
struct PersistenceController
{
static var preview: PersistenceController = {
let result = PersistenceController(inMemory: true)
let viewContext = result.container.viewContext
return result
}()
let container: NSPersistentCloudKitContainer
init(inMemory: Bool = false)
{
container = NSPersistentCloudKitContainer(name: "SBWorkbook")
if inMemory
{
container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
}
guard let description = container.persistentStoreDescriptions.first else
{
fatalError()
}
description.cloudKitContainerOptions?.databaseScope = .public
container.viewContext.automaticallyMergesChangesFromParent = true
container.viewContext.transactionAuthor = "Me"
container.viewContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy
container.loadPersistentStores(completionHandler:
{ (storeDescription, error) in
if let error = error as NSError?
{
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
}