Post

Replies

Boosts

Views

Activity

CloudKit - initializeCloudKitSchema error
Hi, I've previously used a local core data database successfully with my app and now I wanted to use NSPersistentCloudKitContainer to store the data in CloudKit. However when I do container.initializeCloudKitSchema(options: []) I receive an error which I'm not able to comprehend: CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _requestAbortedNotInitialized:](2112): <NSCloudKitMirroringDelegate: 0x6000037b00e0> - Never successfully initialized and cannot execute request '<NSCloudKitMirroringImportRequest: 0x600002dfeee0> 17E8940B-00D6-4D01-AA78-6A04EBEBC957' due to error: <CKError 0x600000032040: "Partial Failure" (2/1011); "Failed to modify some records"; uuid = CED7F4CE-5B7C-4AF9-84F7-AC65C5E431BA; container ID = "iCloud.com.my.identifier"; partial errors: { CD_FAKE_Item_A225280B-016E-4B2E-B9F2-DEAE9F83A856:(com.apple.coredata.cloudkit.zone:__defaultOwner__) = <CKError 0x6000000edcb0: "Invalid Arguments" (12/2006); server message = "Cannot create new type CD_Item in production schema"; op = 1D0AF7734BF5657B; uuid = CED7F4CE-5B7C-4AF9-84F7-AC65C5E431BA> ... 9 "Batch Request Failed" CKError's omited ... }> I also get this error in the console: "Atomic failure" <CKRecordID: 0x60000007dec0; recordName=CD_FAKE_Item_9C9B2AF5-9BB0-4EE1-95F5-1C060C67C0F7, zoneID=com.apple.coredata.cloudkit.zone:__defaultOwner__>" = "<CKError 0x600000e4ea00: \"Batch Request Failed\" (22/2024); server message = \"Atomic failure\"; op = 94FDC06EC8764FC3; uuid = 9BFB7F0A-BA16-4CDC-80FA-F897EF294419; container ID = \"iCloud.com.my.identifier\"> I've tried to reset Reset Environment in the CloudKit dashboard to no avail.
1
0
761
Apr ’23
NSPersistentCloudKitContainer/Core Data design approach
I'm using NSPersistentCloudKitContainer together with a private and public database. I have a public database with articles. Users should be able to like an article but I'm wondering what would be the best design approach to achieve this. The users can also add articles that they find online which are then automatically liked for the user adding it (and uploaded to the public database) Question 1 I want you to be able to see how many people have liked an article, so I think there will perhaps be an array on the article with the userId who liked it and then you just do a count on it? Or do you think there is a better way? Question 2 I am thinking about how the liked article should be "saved" for the user, either put that article in their private database, but then that article will be disconnected from the public article. Or I can filter out among the public articles that contain the user's userId (however, I'm a little unsure how it works in practice as the public database is polled every 30 minutes with NSPersistentCloudKitContainer) and when the user adds an article from some website then he wants that article to appear directly in the app.
0
0
692
May ’23
Field '___modTime' is not marked sortable
I'm using NSPersistentCloudKitContainer and I'm getting warnings in the console saying: CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedExportWithLabel:activity:completionHandler:]_block_invoke(3457): <NSCloudKitMirroringDelegate: 0x2831e40e0> - Finished automatic export - AppActivationExport - with result: <NSCloudKitMirroringResult: 0x280695d70> storeIdentifier: F2C60E7A-CEC4-44F2-B467-7324C065AD33 success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134406 "Request '1FA53D40-43FB-4751-8719-0D26393D5301' was aborted because the mirroring delegate never successfully initialized due to error: <CKError 0x2806798c0: "Invalid Arguments" (12/2016); server message = "Field '___modTime' is not marked sortable"; op = DC861AAA03EBFBF0; uuid = 37A8231D-AB96-4B7C-8132-****9A0C1D39; container ID = "iCloud.com.***">" UserInfo={NSLocalizedFailureReason=Request '1FA53D40-43FB-4751-8719-0D26393D5301' was aborted because the mirroring delegate never successfully initialized due to error: <CKError 0x2806798c0: "Invalid Arguments" (12/2016); server message = "Field '___modTime' is not marked sortable"; op = DC861AAA03EBFBF0; uuid = 37A8231D-AB96-4B7C-8132-****9A0C1D39; container ID = "iCloud.com.***">} I have added indexes for recordName and modifiedTimestamp to all my records as queryable as per the instructions.
2
0
732
May ’23
Can a private database entity have a relationship to a public database entity?
I’m using NSPersistentCloudKitContainer and I’m utilising the public database and also the user’s private database. For example I have an entity called Category which has a many-to-many relationship to an entity called NewsArticle. So the NewsArticles exist in the public database for the user to browse, but he can add them to a category which will live in his private database. So that’s my question, is it possible for an entity which exists a in the private database to have a relationship to another entity in a public database?
1
1
713
May ’23
How to program your iOS app for use with a Bluetooth keyboard
I’m trying to find some documentation on how to properly support a Bluetooth keyboard in an iOS app. I have a custom UIView which consists of some subviews but the Bluetooth keyboard is unable to target (by using the arrow keys on the keyboard) some of the subviews and I want to know what I’m doing wrong. I’ve tried to find official documentation from Apple to no avail.
1
0
567
May ’23
Unable to deduplicate both private and public store
I've successfully followed the sample code from Apple: Synchronizing a local store to the cloud to deduplicate entities that are created in the user's private store. However my app also has a public store that needs deduplication and if I enable the NSPersistentStoreRemoteChangeNotificationPostOptionKey for both the private and public store then no deduplication will occur in my private store. This is reproducible every time by not setting NSPersistentStoreRemoteChangeNotificationPostOptionKey for the public store. Has anyone else experienced this and has anyone got a solution to get it to work? Persistence setup code: private static func makeStoreDescription(for database: Database) -> NSPersistentStoreDescription { let url: URL let scope: CKDatabase.Scope let configuration: String switch database { case .private: url = Self.privateStoreURL scope = .private configuration = "Private" case .public: url = Self.publicStoreURL scope = .public configuration = "Public" } let storeDescription = NSPersistentStoreDescription(url: url) storeDescription.cloudKitContainerOptions = .init(containerIdentifier: Config.cloudKitContainerIdentifier) storeDescription.cloudKitContainerOptions?.databaseScope = scope switch database { case .private: storeDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) storeDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) case .public: // Uncommented otherwise deduplication doesn't work // storeDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) // storeDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) break } storeDescription.configuration = configuration return storeDescription } private static func makeContainer(inMemory: Bool = false, useIcloud: Bool) -> NSPersistentCloudKitContainer { let privateStoreDescription = makeStoreDescription(for: .private) let publicStoreDescription = makeStoreDescription(for: .public) let container = NSPersistentCloudKitContainer(name: "Name", managedObjectModel: managedObjectModel) container.persistentStoreDescriptions = [privateStoreDescription, publicStoreDescription] // Don't save information for future use if running in memory... if inMemory { container.persistentStoreDescriptions.forEach { $0.url = URL(fileURLWithPath: "/dev/null") } } print("useIcloud:", useIcloud) if !useIcloud { container.persistentStoreDescriptions.forEach { $0.cloudKitContainerOptions = nil } } container.loadPersistentStores { storeDescription, error in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } print("Loaded store configuration:", storeDescription.configuration ?? "") } #if DEBUG // Use the container to initialize the development schema. // Only necessary whenever changes have been made to the schema. //try! container.initializeCloudKitSchema(options: []) #endif container.viewContext.automaticallyMergesChangesFromParent = true container.viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump container.viewContext.transactionAuthor = Self.transactionAuthor if !inMemory { do { try container.viewContext.setQueryGenerationFrom(.current) } catch { fatalError("Failed to pin viewContext to the current generation: \(error)") } } return container }
0
0
408
Sep ’23
Field recordName is not marked queryable
I'm using NSPersistentCloudKitContainer and in the CloudKit dashboards I have added indexes for all my records modifiedTimestamp queryable, modifiedTimestamp sortable and recordName queryable. But I'm still getting this warning message in the console. <CKError 0x302acf0c0: "Invalid Arguments" (12/2015); server message = "Field 'recordName' is not marked queryable"; op = FF68EFF8D501AED8; uuid = 12C5C84B-EA9B-41A6-AD85-34023827E6FA; container ID = "z.y.x"> error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _importFinishedWithResult:importer:](1400): <PFCloudKitImporter: 0x30316c1c0>: Import failed with error: <CKError 0x302acf0c0: "Invalid Arguments" (12/2015); server message = "Field 'recordName' is not marked queryable"; op = FF68EFF8D501AED8; uuid = 12C5C84B-EA9B-41A6-AD85-34023827E6FA; container ID = "z.y.x"> error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromError:](2312): <NSCloudKitMirroringDelegate: 0x301b1cd20> - Attempting recovery from error: <CKError 0x302acf0c0: "Invalid Arguments" (12/2015); server message = "Field 'recordName' is not marked queryable"; op = FF68EFF8D501AED8; uuid = 12C5C84B-EA9B-41A6-AD85-34023827E6FA; container ID = "z.y.x"> error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _recoverFromError:withZoneIDs:forStore:inMonitor:](2622): <NSCloudKitMirroringDelegate: 0x301b1cd20> - Failed to recover from error: CKErrorDomain:12 Recovery encountered the following error: (null):0 error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate resetAfterError:andKeepContainer:](612): <NSCloudKitMirroringDelegate: 0x301b1cd20> - resetting internal state after error: <CKError 0x302acf0c0: "Invalid Arguments" (12/2015); server message = "Field 'recordName' is not marked queryable"; op = FF68EFF8D501AED8; uuid = 12C5C84B-EA9B-41A6-AD85-34023827E6FA; container ID = "z.y.x"> error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _requestAbortedNotInitialized:](2200): <NSCloudKitMirroringDelegate: 0x301b1cd20> - Never successfully initialized and cannot execute request '<NSCloudKitMirroringImportRequest: 0x300738eb0> A3F23AAC-F820-4044-B4B9-28DFAC4DE8D7' due to error: <CKError 0x302acf0c0: "Invalid Arguments" (12/2015); server message = "Field 'recordName' is not marked queryable"; op = FF68EFF8D501AED8; uuid = 12C5C84B-EA9B-41A6-AD85-34023827E6FA; container ID = "z.y.x">
1
0
138
1w