Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

NSPersistentCloudKitContainer stop sync when CKErrorDomain 12 error occurred
My app uses NSPersistentCloudKitContainer to implement Coredata and iCloud synchronization data Recently, I received feedback from online users about data synchronization errors, and the error code is CKErrorDomain 12 . In the App, I use NSPersistentCloudKitContainer.eventChangedNotification to monitor the synchronization status, the following is the specific code NotificationCenter.default.publisher(for: NSPersistentCloudKitContainer.eventChangedNotification) .sink(receiveValue: { notification in if let cloudEvent = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey] as? NSPersistentCloudKitContainer.Event { let event = SyncEvent(from: cloudEvent) } }) .store(in: &disposables) When the user feedbacks that the data cannot be synchronized, it can be seen from the above code that an error occurred when CoreData + iCloud was exporting data. At the same time, cloudKitEvent.error does not contain any error information, only CKErrorDomain 12 this information, I don’t know
0
0
1.2k
Apr ’23
Force a NSPersistentCloudKitContainer sync
I have a SwiftUI app sitting on top of a CoreData + CloudKit stack. If I have the app running on multiple devices, a change on one device will not always be reflected on the others. However, restarting the app on the other device will pick up the change. For example:Device A and Device B both have the app running. Device B has it in the background.Device A changes Record 1. Device B returns to the foreground, but does not see the change to Record 1Kill the app on Device B, relaunch, and it sees the changeIt seems that the cloudkit process isn't always getting change notifications from iCloud (note that this happens on actual devices, not just the sim). If we could tell the container Hey, I just retuned to the foreground, maybe check to see if anything has changed?, that would, I think, fix the problem. I can't tear down my CoreData stack without rebuilding the entire app (since the main thread context is pushed down into SwiftUI).Is there a way to force this update?Thanks!Ben
4
0
4.7k
Nov ’19
Reply to SwiftData and CloudKit not synching between devices
Our general set of debugging / inspection Tech Notes are: https://developer.apple.com/documentation/technotes/tn3163-understanding-the-synchronization-of-nspersistentcloudkitcontainer https://developer.apple.com/documentation/technotes/tn3162-understanding-cloudkit-throttles https://developer.apple.com/documentation/technotes/tn3164-debugging-the-synchronization-of-nspersistentcloudkitcontainer
Oct ’25
Reply to Help with 2 way relationships with classes (SwiftData / cloudkit)
The error message you provided, “container not found errors“, doesn't seem to indicate anything related to your data model. If you can provide full description of the error, and also how you trigger the error, I may be able to comment. SwiftData's CloudKit integration is based on NSPersistentCloudKitContainer. You can also follow the following technotes to understand and debug any synchronization issue: TN3163: Understanding the synchronization of NSPersistentCloudKitContainer. TN3164: Debugging the synchronization of NSPersistentCloudKitContainer. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Sep ’24
Strange behavior with 100k+ records in NSPersistentCloudKitContainer
I have been using the basic NSPersistentContainer with 100k+ records for a while now with no issues. The database size can fluctuate a bit but on average it takes up about 22mb on device. When I switch the container to NSPersistentCloudKitContainer, I see a massive increase in size to ~150mb initially. As the sync engine uploads records to iCloud it has ballooned to over 600mb on device. On top of that, the user's iCloud usage in settings reports that it takes up 1.7gb in the cloud. I understand new tables are added and history tracking is enabled but the size increase seems a bit drastic. I'm not sure how we got from 22mb to 1.7gb with the exact same data. A few other things that are important to note: I import all the 100k+ records at once when testing the different containers. At the time of the initial import there is only 1 relation (an import group record) that all the records are attached to. I save the background context only once after all the records and the import group have been made and
3
0
703
Sep ’24
Reply to CloudKit in TestFlight: No sync between devices 😭
In this situation, you might consider capturing and analyzing a sysdiagnose. The following technote discusses how to do so: TN3163: Understanding the synchronization of NSPersistentCloudKitContainer The following related technote may also help: TN3164: Debugging the synchronization of NSPersistentCloudKitContainer Best, —— Ziqiao Chen  Worldwide Developer Relations.
Jun ’24
Initialize NSPersistentCloudKitContainer with iOS 14 and Public DB
I'm struggling to initialize my schema. I keep getting the error : 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 Without the initialize it does sometimes create the record's schema. But it feels like its all half working. I have Cloudkit on and Used with Cloudkit is checked under the default configuration in my xcdatamodeld file. Here is my setup code.. _persistentContainer = [[NSPersistentCloudKitContainer alloc] initWithName:@Eco-nomy]; // Add options and make this container PUBLIC. NSPersistentStoreDescription *description = _persistentContainer.persistentStoreDescriptions.firstObject; [description setOption:[NSNumber numberWithBool:YES] forKey:NSPersistentHistoryTrackingKey]; [description setOption:[NSNumber numberWithBool:YES] forKey:NSPersistentStoreRemoteChangeNotificationPostOptionKey]; description.cloudKitContainerOptions.databas
0
0
736
Feb ’21
NSPersistentCloudKitContainer migration with custom NSEntityMigrationPolicy
Recently, I have made quite extensive changes to my schema and need to migrate my CoreData + CloudKit model to a new version. The changes require me to use a custom NSEntityMigrationPolicy because I have a rather complex mapping between some old entities and new entities. I have added a new model version. Deleted some entities, and added some entities. I have defined the NSEntityMigrationPolicy with createDestinationInstances(forSource:in:manager:) and createRelationships(forDestination:in:manager:). I have created a new Core Data Mapping Model. This was probably unnecessary. Within the Core Data Mapping Model, I have specified Custom Policy for all entities. In my container setup, I added two options, as below: storeDescription.setOption(false as NSNumber, forKey: NSMigratePersistentStoresAutomaticallyOption) storeDescription.setOption(false as NSNumber, forKey: NSInferMappingModelAutomaticallyOption) I mostly followed a Core Data Heavyweight Migration guide. I'm unable to share the link, but it can be quite
1
0
695
May ’24
Reply to CoreData+CloudKit custom Zone
Are you using manually syncing your CloudKit with CoreData or are you using NSPersistentCloudKitContainer? If you using NSPersistentCloudKitContainer does the syncing for you, don't have to set any custom zone, it would set a custom zone automatically. If you are doing it manually, then you would need to set a custom zone when you are saving a record and when you are retrieving it not while loading the container's persistent stores (which is what you are doing).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
NSPersistentCloudKitContainer Import failed (incomprehensible archive)
I am using NSPersistentCloudKitContainer and I decided to add a property to an entity. I accidentally ran try! container.initializeCloudKitSchema(options: []) while using the production container in Xcode (com.apple.developer.icloud-container-environment) which throw a couple of errors and created some FAKE_ records in my production container. So I changed to my development container and ran the try! container.initializeCloudKitSchema(options: []) and now it succeeded. After that I cleaned up the FAKE_ records scattered in production container but in Xcode when I'm running I now get these logs in the console (and I can't seem to get rid of them): error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _importFinishedWithResult:importer:](1398): : Import failed with error: Error Domain=NSCocoaErrorDomain Code=4864 *** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x73, 0x61, 0x6d) UserInfo={NSDebugDescription=*** -[NS
3
0
540
Dec ’24