I'm trying to use NSPersistentCloudKitContainer.initializeCloudKitSchema() to initialise a public CloudKit database, but it seems to fail when any given entity has more than two String fields (or, it seems, any two fields which NSPersistentCloudKitContainer decides need to be CKAsset-backed).
I've raised rdar://FB8995024 about this too, but was wondering if someone here can see something I'm missing.
I can consistently reproduce this on iOS 14.4 (18D46) on the iOS Simulator with Xcode 12.4 (12D4e), or with an iPhone 11 Pro running iOS 14.4 (18D52) using this code (in a new iOS App project, SwiftUI/SwiftUI App/Swift, Use Core Data+Host in CloudKit) and a single Core Data entity with two String attributes:
Code Block swift import CoreData import SwiftUI @main struct NSPersistentCloudKitContainer_initTestingApp: App { let persistenceController = PersistenceController.shared var body: some Scene { WindowGroup { Text("Success") } } } struct PersistenceController { static let shared = PersistenceController() let container: NSPersistentCloudKitContainer init() { container = NSPersistentCloudKitContainer(name: "NSPersistentCloudKitContainer_initTesting") // If we change this to .private, everything is fine container.persistentStoreDescriptions[0].cloudKitContainerOptions?.databaseScope = .public container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } }) do { try container.initializeCloudKitSchema() } catch { fatalError("###\(#function) Error initialising CloudKit schema: \(String(describing: error))") } } }
Thanks!