Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

Cloudkit - Coredata and multiples database
Today, I'm working without cloudkit (all data are in a local Coredata), with one database on my Xcode project but with 2 containers on app.delegate : one for a test environment : with storeURL ---> test.sqlite one for a production environment : with storeURL --> production.sqlite Everything is ok, the test data, is really separate from production data. Now, I try to use cloudkit functions : I change NSPersistentContainer to NSPersistentCloudKitContainer it's working and I could use data on 2 iPads. BUT if I switch the test to the prod, now the data from test environnement is duplicate on the production environnement. what mistake am I making? How could I use my two storeURL with cloudkit coredata? Thanx for your help.
2
0
723
Jan ’22
Avoid Duplicate Records with CloudKit & CoreData
When my app starts it loads data (of vehicle models, manufacturers, ...) from JSON files into CoreData. This content is static. Some CoreData entities have fields that can be set by the user, for example an isFavorite boolean field. How do I tell CloudKit that my CoreData objects are 'static' and must not be duplicated on other devices (that will also load it from JSON files). In other words, how can I make sure that the CloudKit knows that the record created from JSON for vehicle model XYZ on one device is the same record that was created from JSON on any other device? I'm using NSPersistentCloudKitContainer.
3
0
3.3k
Feb ’22
Reply to Avoid Duplicate Records with CloudKit & CoreData
NSPersistentCloudKitContainer doesn’t support unique constraints today. To make sure that a record is unique across devices, you need to implement your own mechanism. In case you are interested in doing that, I have a sample project (I use it as my testbed) that may help: Sharing Core Data Objects Between iCloud Users It is a SwiftUI project that supports iOS and watchOS, and covers the following topics: Creating the CloudKit Schema for Apps Setting up the Core Data Stack Sharing a Core Data object Detecting Relevant Changes by Consuming Store Persistent History Removing Duplicate Data Implementing a Custom Sharing Flow #4 and #5 are probably the most relevant to your question. Feel free to provide your feedback here so I can improve the project and hopefully better help.
Feb ’22
NSPersistentCloudKitContainer exclude relationship from share
I am trying to add CloudKit sharing to my app using the new iOS 15 share method https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer/3746834-share In the app there are 3 core data entities (Folder, Item, Comment) with the following relationships: A Folder contains many Items An Item has many Comments I want to use CloudKit to share just the Item entity, not any of its relationships. Is this possible to do with the share(_:to:completion:) method? Currently, when I pass an Item to the share method it also includes the Folder and Comments in the CKShare. How do I prevent this?
1
0
977
Feb ’22
Cannot migrate store in-place: CloudKit integration forbids renaming
Background Core Data driven app, successfully using NSPersistentCloudKitContainer for some time. App is written 100% SwiftUI, currently targeting iOS and macOS targets. Development only, no production release yet. Error... ... Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134110 An error occurred during persistent store migration. ... reason=Cannot migrate store in-place: CloudKit integration forbids renaming 'foodServes' to 'foodPortions'. Older devices can't process the new relationships. An unusual problem for me... the renaming occurred between version 7 and version 8 of the Core Data model and this is version 13. So if I revert back to version 12, there is no issue. It is only when I add the new Entity in model version 13 that the error occurs. The new entity incudes a relationship back to two other existing entities, but not the Food entity that contains the foodServes -> foodPortions renamingID. To be clear, the error relates to a renamingID that was implemented in the
1
0
2.0k
Feb ’22
NSPersistentCloudKitContainer - notification
I would like to implement notifications about NSPersistentCloudKitContainer I find this classe but I receive no notifications in my app!?! Do I need more settings to use it? thanx for your help import Combine import CoreData @available(iOS 14.0, *) class SyncMonitor { /// Where we store Combine cancellables for publishers we're listening to, e.g. NSPersistentCloudKitContainer's notifications. fileprivate var disposables = Set() init() { NotificationCenter.default.publisher(for: NSPersistentCloudKitContainer.eventChangedNotification) .sink(receiveValue: { notification in if let cloudEvent = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey] as? NSPersistentCloudKitContainer.Event { // NSPersistentCloudKitContainer sends a notification when an event starts, and another when it // ends. If it has an endDate, it means the event finished. if cloudEvent.endDate == nil { print(Starting an event...) // You could check the type, but I'm trying to keep this bri
1
0
1.9k
Mar ’22
Reply to NSPersistentCloudKitContainer - Import failed because applying the accumulated changes hit an unhandled exception
Update for anyone else with this issue. Here is the reply I have received from Framework engineers in response to bug report We have additional information, the root cause of this issue is a large number of incoming images in the same import. You can work around this by syncing your images with CloudKit directly via a CKRecord you own (instead of letting NSPersistentCloudKitContainer do it). We will continue to improve the performance of NSPersistentCloudKitContainer and followup again in this feedback report when the issue is resolved.
Mar ’22
Unable to handle conflict reported by NSCloudKitMirroringDelegate
I'm working on an app that uses NSPersistentCloudKitContainer to handle CloudKit sharing. Against all odds I've gotten the sharing to work, but now I'm seeing errors on startup that look very much like some kind of background loop trying to merge changes from multiple users and failing. In a more traditional CloudKit installation not backed on NSPersistentCloudKitContainer this feels like a case where I'd have to provide some code to handle the merge. In the brave new world I can't seem to find anyway to affect this Mirroring Delegate. It starts when I initialize the NSPersistentCloudKitContainer and produces the error below (as well as a long stream of similar errors). Any ideas? error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _exportFinishedWithResult:exporter:](1347): : Export failed with error: , hasProtectionInfo=true, invitationTokenStatus=Healthy, isAnonymousInvitedParticipant=false> ) === Server: ( , cached=false, publicKeyVersion=2>, hasProtectionInfo=true, in
1
0
1.1k
Mar ’22
Reply to NSPersistentCloudKitContainer - Import failed because applying the accumulated changes hit an unhandled exception
Please file a bug report with Apple using Feedback, if you haven't already done so. Quote my report FB9859660. I am in the same situation as you, and feel as though I'm the only one! I too don't know what to say to my users, other than Apple have a bug and they are working on it, with no timescale for resolution. People are not happy! It was working perfectly well in iOS14. Now it's not in iOS15. Instruments suggests to me that there is probably a memory leak in NSPersistentCloudKitContainer. Large spikes in Virtual Memory usage on all imports (even the small ones) but the small ones dont trigger a crash. The same (smallish) database in iOS14 uses 36MB of VM but in iOS15 uses 1.49GB for example!!
Mar ’22
'Transaction' is ambiguous for type lookup in this context - SwiftUI
I'm developing a SwiftUI multi-platform, multi-user app for family budget management (not for the App Store) using CoreData and iCloud with NSPersistentCloudKitContainer. I use manual Codegen in Xcode to generate the CoreData entity classes, then add extensions for computed properties. These are in my DataModel (ViewModel), which is in an included framework. All data processing is done in the data model. All's working fine in the SwiftUI Views, except for one entity - 'Transaction', which throws a compiler error 'Transaction' is ambiguous for type lookup in this context. Some SO posts say to use the App Name as a prefix to the type, but this doesn't work. What does solve it, in this case, is to use the name of the Framework (Library) holding the type definition: import SwiftUI import OurMoneyLib // my framework holding the DataModel and CoreData entity classes struct TransactionRow: View { let appAPI = AppAPI() var transaction : OurMoneyLib.Transaction var body: some View { ...... Why this one entity
1
0
3.2k
Mar ’22
Reply to File System vs Core Data for persisting data
adding to Claude31, SwuiftUI's @FetchedResults, and the underlying NSFetchedResultsController, are IMHO a key reason to adopt CoreData: changes in the background at the model layer get signaled to the main thread view layer, which can then be dynamically updated. The other reason to use CoreData is enabling device-to-device synchronization (for a user with multiple devices, or data shared between users) via NSPersistentCloudKitContainer (or an open-source sync engine like CloudCore).
Mar ’22
Reply to CloudKit and Serial-port Communication
I have done research on serial port communication using a macOS app a little bit ago but it seems like I will need to use a Command-line tool program. Is this correct? If I do go the Command-line tool route I will have to use cktool I believe. Will cktool allow me to use NSPersistentCloudKitContainer or similar command to allow a silent notification type fetch data system?
Mar ’22
CoreData: preview canvas won't work with 2x entities and relationship
I've tried to create a simple CoreData entity and use the PreviewProvider to display the results. This worked fine (The first entity that got displayed was the GoalInformation). After this i've extended my entity with a relationship to another entity. This is a screenshot from the Xcode editor: More information about the entities: This is my ContentView struct ContentView: View { @Environment(.managedObjectContext) private var viewContext @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: Goal.information!.name, ascending: true)], animation: .default) private var items: FetchedResults var body: some View { VStack { Text(count: (items.count)) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() .environment(.managedObjectContext, PersistenceController.preview.container.viewContext) } } The preview of the PersistenceController looks like this: static var preview: PersistenceController = { let result = PersistenceController(inMemory: true) let viewContext =
1
0
1.3k
Apr ’22
Timeout during initialization of CloudKit schema
Hi everybody, I am having trouble further initializing my CloudKit schema with an NSPersistentCloudKitContainer and store descriptions for booth public and private database scopes. The execution environment is macOS 12.3.1. container.newBackgroundContext().perform { do { print(Starting to initialize CloudKit Schema...) try container.initializeCloudKitSchema(options: []) print(CloudKit Schema succesfully initialized.) } catch { print(error) } } After about 30 seconds, the above code block goes into the catch statement with the following error: Error Domain=NSCocoaErrorDomain Code=134060 A Core Data error occurred. UserInfo={NSLocalizedFailureReason=Failed to initialize CloudKit schema because the requests timed out (a 30s wait failed).} During that 30 seconds of my app trying to init the schema, I noticed that the CloudKit Console was also having trouble communicating correctly with the container: When I reload the CloudKit Console after the init got into the 30s timeout. The Console has no more troub
2
0
1.4k
Apr ’22