我在尝试初始化 Cloudkit架构时收到此错误:
Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={NSLocalizedFailureReason=Couldn't initialize CloudKit schema because no stores in the coordinator are configured to use CloudKit: ()}
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
private lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentCloudKitContainer(name: self.objectModelName)
// Create a store description for a CloudKit-backed local store
let cloudStoreLocation = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("iCloud.sqlite")
let cloudStoreDescription = NSPersistentStoreDescription(url: cloudStoreLocation)
cloudStoreDescription.configuration = "iCloud"
// Set the container options on the cloud store
cloudStoreDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.myname.app")
// Update …Run Code Online (Sandbox Code Playgroud)