for iOS 14+ there is notification to let you know that your data exported and imported and other events type. `` if let cloudEvent = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey] as? NSPersistentCloudKitContainer.Event }`` but to make compatibility my app with iOS 13, if there any event type exist like above for NSPersistentCloudKitContaine?
Search results for
NSPersistentCloudKitContainer
589 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi, I have implemented iCloud Sync using NSPersistentCloudKitContainer. However, I have a lot of data to sync in my use case which can take quite some time (minutes) especially when starting with a new device (10's of minutes). I was wondering if there is a way to make good use of BGProcessingTaskRequest (ie long running task over night, potentially with requiresExternalPower). The idea is to let the device catch up with the remote store during such a long running background task over night/during charge. I already tried to hack my way into this by trying to just listen to sync events during the task and not finish the task until sync events have stopped but it seems the sync processor does have its own awareness of the app moving to the background and therefore might not even wake up during the background task. Any idea how I can help the CloudKitContainer to catch up in the background with very large workloads? Thanks!
hi, i would think your easiest solution is to use the built-in linkage between Core Data and CloudKit using NSPersistentCloudKitContainer. this takes care of all of your concerns: your data is stored locally in Core Data and mirrored to/from the cloud for you. everything works fine when offline or not signed in to iCloud. just remember that in this design, the Cloud becomes the source of truth for your data. modify data on one device; it is synced with iCloud; and then the data is synced with your other devices, where their local Code Data store is synced to match what's in the cloud. there would be no option for the user here to choose which data they want to use, as you say, the backed-up data or the new data. once your device is online and signed into iCloud, your on-device data will be synced to be a mirror of what's in the cloud. hope that helps, DMG
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I keep getting the error below when connecting my app that uses a NSPersistentCloudKitContainer. I have made no changes to the code in months and I was working reliably. The error seems random and can sometime be resolved by disconnecting and re-connecting from wifi. It is not just my app but other apps that use CloudKit as well for synch. I know there were issues that were supposed to be fixed but this is happening every day now. Can anyone shed some light on this? [error] error: CoreData+CloudKit: -[PFCloudKitImporter databaseFetchFinishWithContext:error:completion:](249): : Database fetch for request: 58556A21-BDE3-49C6-A4E9-C1DAE2752629 failed with error:
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
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 =
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?
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
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).
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
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
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!!
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
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
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
CloudKit
wwdc21-10015
wwdc21-10086
wwdc21-10117
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.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
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
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
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?