Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

NSCloudKitMirroringExportRequest issues
I'm attempting to create a Swift/SwiftUI app that will run on iOS/iPadOS that uses CloudKit to syncronize data between devices. I have created the App in Xcode.In the Apps Signing & Capabilities tab, I have:- Ensured that the Bundle Identifier is valid- Added the iCloud capability - Created the Container and checked it - Validated that the Container was created in the CloudKit Dashbaord- Added the Backgrouind Modes capability - Checked the Remote notifications optionI have modified/validated AppDelegate.swift:- Validated that it is using NSPersistentCloudKitContainer- Added container.viewContext.automaticallyMergesChangesFromParent to true- Added container.viewContext.mergePolicy to NSMergeByPropertyObjectTrumpMergePolicyWhen I load the App, I get a series of errors reported related to CloudKit NSCloudKitMirroringExportRequest. These errors are shown below. I am able to create records, but can see they are only stored locally and do not get synced to the CloudKit Dashboard - interestingly enough,
21
0
14k
Apr ’20
NSPersistentCloudKitContainer not syncing data on macOS
Hello, I am using NSPersistentCloudKitContainer to share data between iOS and macOS app.I have set up the project according to the official tutorials. And when I made changes from the macOS app, the lastest data will automatically display on my iOS app. But in the other direction when I made changes on iOS, macOS app will not get the lastest version of the data.I have verified on Cloud Dashboard that the changes made on iOS have been uploaded onto CloudKit server. Just the macOS app and the cloudd process won't create tasks to pull these changes (observed from console.app). And if I quit the macOS app and restart it, lastest data will be pulled.So the problem is that macOS using NSPersistentCloudKitContainer will not get synced data in the runtime.One potential reason is that the official tutorial has mentioned to set the background Remote Notification. I've done this for the iOS app. But for the macOS app, there are no background mode options so I skipped this step.Any ideas to get the sync
4
0
1.3k
Apr ’20
NSPersistentCloudKitContainer reverts NSManagedObject subclass to old value
I have an app that uses NSPersistentCloudKitContainer to synchronise data with iCloud. Users reported occasional data loss after which I started debugging my implementation.Part of my app’s implementation is showing a pop-up that displays information and has a confirm button. When the user clicks this button, one or more instances of a custom NSManagedObject subclass gets modified.At the same time, NSPersistentCloudKitContainer triggers a mirror process when the app resigns and becomes active. This happens when the user clicks the above mentioned confirm button. It does this by executing a NSCloudKitMirroringExportRequest and NSCloudKitMirroringImportRequest request.In other words, in my app, data gets modified (explicitly via code) and gets mirrored (implicitly via CloudKit) at the same time, and this is where things go wrong.Essentially this is what happens:1. A property (NSTimeInterval) of an instance of an NSManagedObject subclass gets incremented (e.g. 0 + 1 = 1).2. NSPersistentCloudKitContainer
2
0
1.3k
Apr ’20
NSPersistentCloudKitContainer and CloudKit for Sharing
Hello,I've tried to figure this out for weeks now, but can't find a solution. I am not very experienced in App Development yet, so maybe it can be solved with little effort and I just don't know how...?I am working on a baby journal app where parents should be able to share a child record together with all its entries (existing ones and ones that are going to be added in the future) to be able to both edit and add and look at entries. So, I need sharing like in the Apple Notes App.I am using core data and the new NSPersistentCloudKitContainer. The core data model consists of a child record and entities that are referencing to the child.I know that at the moment NSPersistentCloudkitContainer doesn't support sharing.I have no clue how to add sharing with CKShare API beside the core data stuff. To have a proper solution, do I need toa) throw away NSPersistentCloudKitContainer and solely base the app on CloudKit API with no core data at all?b) add CloudKit Sharing via CKShare API, exist
4
0
3.5k
Apr ’20
Where's the documented record method for NSPersistentCloudKitContainer?
I would need to access CKRecords of my NSManagedObjects on iOS 13.4 and there seems to be a documented method in NSPersistentCloudKitContainer, but the compiler can't see it! How this can be?Compilation error:https://vesacdn.s3.eu-north-1.amazonaws.com/compilation+error.pngClass definition seen by xcode 11.4.1:https://vesacdn.s3.eu-north-1.amazonaws.com/NSPersistentCloudKitContainer.pngDocumented:https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer
1
0
526
May ’20
NSPersistentCloudKitContainer stops syncing
I have moved my NSPersistentContainer in my app to an NSPersistentCloudKitContainer to sync data between devices (iPhone, iPad, and Apple Watch supported). Sync works just fine in test & production, but after a few days it will stop working and behave as if each device is using local storage. This continues to happen until I reinstall the app and it syncs again, but only for a short time until it goes back to using local storage again. Does anyone know of a way to debug this?
3
0
882
May ’20
CoreData+CloudKit Model Migration Failing
So I've been developing happily with CoreData+CloudKit for a while now, and really haven't run into any issues until this. I've migrated my model a couple of times, and it worked fine, but this was the first time I added a new entity to the model. If I run on a device (any device, iPhone, iPad, Mac via Catalyst), I get a migration error. Here's the entirety of my persistentContainer setup: public var persistentContainer: NSPersistentContainer = { let modelPath = Bundle(for: CoreDataStack.self).url(forResource: Progress, withExtension: momd)! let model = NSManagedObjectModel(contentsOf: modelPath)! let container = NSPersistentCloudKitContainer(name: Progress, managedObjectModel: model) container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { print(storeDescription) fatalError(Unresolved error (error), (error.userInfo)) } }) return container }()And here's the error I'm getting:Callstacks=true}}}CoreData: annotation: : Attempting recovery from e
10
0
5.8k
Jun ’20
CloudKit, 2 quick saves, error: "Could not merge changes"
I'm experimenting with Core Data and CloudKit using the recommended `NSPersistentCloudKitContainer`. I'm kind of new to Core Data so maybe I'm doing something simple/stupid. I get an error when changing the object twice, quickly.I have a SwiftUI view of one of my managed objects, with button toggle the isActive property. If I tap it twice in a row, I get an error from `NSManagedObjectContext.save`. How do you prevent or recover from this kind of error?It seems to be a timing thing, because I'm having trouble duplicating it. private func toggleActiveState() { exercise.isActive = !exercise.isActive try! moc.save() // error }RobFatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=133020 Could not merge changes. UserInfo={conflictList=( NSMergeConflict (0x282fb15c0) for NSManagedObject (0x2819ca8a0) with objectID '0xb61bc172bb432131 <x-coredata://6C618B32-5866-4E35-93C9-3B7F3D221FE6/MyObject/p7>' with oldVersion = 4 and newVersion = 5 and old object snap
1
0
940
Jun ’20
What's the best approach to prefill Core Data store when using NSPersistentCloudKitContainer?
Hello,I'm parsing objects from a JSON file and store them into my Core Data store.I'm using NSPersistentCloudKitContainer and when I'm running the app on a different device, it also parses the JSON file and adds objects to Core Data. That results in duplicate objects.How can I check that an entity already exists remotely ?
2
0
1.4k
Jun ’20
Reply to Spurious pop and re-push during state changes
You wrote: [objectID] certainly changes from run to runI'm not seeing that. It seems to be completely consistent. I was using `objectID.uriRepresentation()` to implement `Identifiable`, and the docs for `uriRepresentation` say it is archivable, which suggests to me that it doesn't change. (?) I'm using `NSPersistentCloudKitContainer`, if that matters.I think that what's getting me now is...ForEach(dataSource.fetchExercises(moc:moc)) { ex in NavigationLink(destination: ExerciseView(exercise: ex)) { ListItemView(exercise: ex) } }If that detail view (ExerciseView), changes the exercise in way that should _reorder_ the results of fetchExercises and the ForEach, then I make `dataSource` (which is an observable object) emit `objectWillChange`. As expected, SwiftUI re-calls `fetchExercises`. But sadly, it pops off the detail view (ExerciseView) and returns to this list view.I thought it should see that the exercise objects have the same IDs, so it would keep the ExerciseView pushed.I too am interested to se
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’20
NSPersistentCloudKitContainer: Set To-One relation to nil is not synced to CloudKit
Using NSPersistentCloudKitContainer: I have a relation between Item --to-one--> Group. This works fine on device: I can set a Group for an Item and remove the Item from the Group again, everything is persisted locally. The Problem: Adding does work, but removing the Group never appears on a different device. As soon as the Item gets edited on the different device, the Group relation re-appears with the new changes (even if manually removed there as well). What I see in CloudKit dashboard: Group field on Item is of type String. A fresh Item record, never assigned to a Group, does not have the Group field. Removing the Group does not remove the Group field in CloudKit. As soon as it gets a Group field, I can’t get rid of it. Manually emptying the value causes to crash on download. Reproducible with the example project: The behaviour can easily be reproduced with the example project (https://developer.apple.com/documentation/coredata/synchronizing_a_local_store_to_the_cloud?language=objc). Just repla
6
0
1.2k
Jun ’20
Reply to NSPersistentCloudKitContainer: Set To-One relation to nil is not synced to CloudKit
You can use the feedback assistant to file bugs against NSPersistentCloudKitContainer. Include the following: A sysdiagnose from all of the participating devices The persistent store files from all of the participating devices If your dataset is large, a detailed accounting of the affected records and the mutations made to them from each device (as well as you recall, history tracking is the truth)
Jun ’20
Reply to What's the best approach to prefill Core Data store when using NSPersistentCloudKitContainer?
How can I check that an entity already exists remotely ? In theory you could write some CloudKit code to execute a CKQueryOperation that checks for your seed content. But that won't handle the race between a device exporting the data and another device launching the app and parsing the json file. You can also check if records exist in the local store using NSFetchRequest. However for the same reason that won't prevent you from inserting duplicate records on multiple devices if they haven't synced with the CloudKit server yet. There are a number of approaches to seeding your application store with content in a reliable way: Don't sync the seed content, instead use an un-synced store to hold the data from the JSON file and a synced store to hold user data Unique the seed content on each device as it is updated by NSPersistentCloudKitContainer Unfortunately NSPersistentCloudKitContainer does not support unique constraints yet, you can file a feedback request for that though.
Jun ’20
Reply to Sharing Core Data with watch app in SwiftUI
AFAIK Watch apps do not naturally sync data back to the companion. This has to be done via one or more of these solutions, Keeping Your watchOS Content Up to Date - https://developer.apple.com/documentation/watchkit/keeping_your_watchos_content_up_to_date. The easiest way to do that would be NSPersistentCloudKitContainer, however WatchConnectivity - https://developer.apple.com/documentation/watchconnectivity may be a better fit depending on your needs.
Jun ’20