Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

Cloudkit Share Updating Core Data NSManaged Objects
I have a simple shopping list app that is using Core Data with Cloudkit. A user creates a list then adds items to the list. The list can be shared to other users. Core Data is first used to save the Lists and Items as NSManaged Objects. A list is then shared to another user who can add to items to the list, and both users working on the same list stay in sync with each other. This is all mostly working but I am having some trouble getting Core Data to update the locally stored NSManaged objects with changes from the Cloud Kit Share. Currently the app is dealing with a mix of NSManaged Objects and CKRecords to display in the table View that shows the items on a list. Which is a bit messy. I really want to just work with NSManaged Objects with Cloudkit doing the work of keeping things in sync between the 2 users. When User B adds an Item it successfully saves to the Shared Database and sets the parent as the list that was shared. This is where I get a bit stuck as I want User A to see the Item that User B added
0
0
701
Apr ’21
Privacy Nutrition Label with encrypted CloudKit attributes
Situation I'm working on an app in which the user can manually enter in data. That data gets locally stored in a CoreData database and from there automatically synced (via NSPersistentCloudKitContainer) to the user private CloudKit database and I selected CloudKit encryption for every attribute. So as the developer I definitely can't access it, but it's stored on some remote server. Ambiguous Documentation The privacy site at https://developer.apple.com/app-store/app-privacy-details/ says stuff like: “Collect” refers to transmitting data off the device in a way that allows you and/or your third-party partners to access it for a period longer than what is necessary to service the transmitted request in real time. If you collect data about your app from Apple frameworks or services [such as MapKit, CloudKit, or App Analytics] you should indicate what data you collect and how you use it. You are not responsible for disclosing data collected by Apple. It's a bit unclear if Apple a third-party in this cas
0
0
935
Jul ’22
FB11794798: NSPersistentCloudKitContainer throws lots of error / debug messages
Hi, When using NSPersistentCloudKitContainer lots of error / debug messages are shown in Xcode Debug area. Feedback FB11794798: Overview When I use NSPersistentCloudKitContainer I get the following error / debug messages printed on the Xcode Debug Area. Syncing seems to happen fine. Tested on device and simulator. I am still using Development (not deployed to Production yet) I even tried with a new project using the default code generated for by enabling CloudKit coredata sync and I still get the same messages. I have filed a feedback FB11794798 Steps to Reproduce Create a new project check Use CoreData and Host in CloudKit check boxes Run the project Notice the error messages shown below. Questions How to resolve these errors? Or is this a bug from the Apple Frameworks? (Feedback FB11794798) Error / debug message printed on Xcode debug area CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: containerIdentifier:
0
0
1.4k
Nov ’22
CloudKit keeps syncing after being turned off until the app is relaunched
In the following code, I'm saving and syncing objects in Core Data and CloudKit, everything is working fine, once the user creates some objects, the data starts syncing as soon as the user turns the Toggle switch On in the SettingsView. The issue I'm having is that the data continue syncing even after the switch is turned Off until I kill and relaunch the app. After relaunching the app, the data stops syncing. Any idea what could I do to make sure that the data stops syncing as soon as the toggle switch is turned off? Again, everything would work fine if the user would kill and relaunch the app right after turning it off, the data stops syncing. I thought that by calling carViewModel.updateCloudKitContainer() right after turning it off would do the trick since I'm disabling the CloudKit container by making it nil, description.cloudKitContainerOptions = nil but obviously is not enough. Core Data Manager class CoreDataManager{ // Singleton static let instance = CoreDataManager() @AppStorage(UserDefaults.Keys.iC
0
0
836
May ’23
CloudKit NSPersistentCloudKitContainer Bug
Hi, does someone knows about the bug, that the NSPersistentCloudKitContainer doesn't return CKShares at the first time? Is this an intended behavior? My current fix: let container: NSPersistentCloudKitContainer = .... // Fix begin let managedObject = .... // Object which is in a share let record = container.record(for: managedObject.objectID) // Fix end let shares = (try? container.fetchShares(in: nil)) ?? [] If I execute exactly the same code without the fix that I fetch the record first, then it returns 0 shares. With the fix it is currently 9 shares (the actual count of the shares). Another fix: let container: NSPersistentCloudKitContainer = .... // Fix begin let _ = try? container.fetchShares(in: nil) Thread.sleep(forTimeInterval: 0.1) // Fix end let shares = (try? container.fetchShares(in: nil)) ?? [] For that fix it also returns at the second time the expected count of shares. But without the delay it returns also at the second time zero shares. Anyone had the same problem and
0
0
565
May ’24
Understanding Syncing between Core Data and CloudKit Public Database using NSPersistantCloudKitContainer
Can someone please give me an overview of how sync works between Core Data and the public CloudKit database when using the NSPersistentCloudKitContainer and please point out my misunderstandings based on what I describe below? In the following code, I'm successfully connecting to the public database in CloudKit using the NSPersistentCloudKitContainer. Below is how I have Core Data and CloudKit set up for your reference. In CloudKit I have a set of PublicIconImage that I created manually via the CloudKit Console. I intend to be able to download all images from the public database at the app launch to the local device and manage them via Core Data to minimize server requests, which works but only if the user is logged in. This is the behavior I see: When the app launches, all the CloudKit images get mirrored to Core Data and displayed on the screen but only if the user is logged in with the Apple ID, otherwise nothing gets mirrored. What I was expecting: I was under the impression that when co
0
0
576
Jun ’24
Public Database delete records (NSPersistentCloudKitContainer)
As I understood there is no built-in mechanism to propagate deletion operations to other devices automatically (CoreData + CloudKit - public database), in order to delete or simulate a deletion do I have to add an attribute to the entities I create in order to simulate a tombstone? and if so I would never really delete the items? or if I do delete them how would I do it? I watched WWDC20 however is still not clear for me how to implement it
0
0
402
Jun ’23
Convert Coredata PersistenceController to SwiftData container
Hello I have a CoreData PersistenceController and would like to convert it to a SwiftData container. Before converting the whole app to use SwiftData I wanted to know if my conversion is right and preserves old data (in iCloud and local). Here is the code: PersistenceController: import CoreData import SwiftUI import Combine #if os(iOS) || os(macOS) || os(watchOS) import WidgetKit #endif struct PersistenceController { static let shared = PersistenceController() let container: NSPersistentCloudKitContainer init() { let fileContainer = URL.storeURL(for: group.Water-Alert-App, databaseName: CoreData) container = NSPersistentCloudKitContainer(name: CoreData) let defaultDirectoryURL = NSPersistentContainer.defaultDirectoryURL() let localStoreURL = defaultDirectoryURL.appendingPathComponent(Local.sqlite) let localStoreDescription = NSPersistentStoreDescription(url: localStoreURL) localStoreDescription.configuration = Local // Create a store description for a CloudKit-backed local store let cloudSto
0
0
704
Jan ’24
NSPersistentCloudKitContainer - mirror sync
My app uses a mirrored CoreData Store with NSPersistentCloudkitContainer. The user has the option to turn cloudKit sync on or off by device. The app responds by setting the description?.cloudKitContainerOptions = nil - but keeps historyTracking on by setting description?.setOption(true as NSNumber,forKey: NSPersistentHistoryTrackingKey) The app is working fine this way with multiple devices and if the user re-enables sync on a particular device that was either disabled or offline everything syncs just fine on all devices. I now want to prune History transactions and I intend to clear the history older than say 7 days only when I receive a NSPersistentStoreRemoteChangeNotificationPostOptionKey observation on transactions that are outside the app. Does a device that was either offline or had sync disabled as per above then re-enabled or come back online upload its local changes first then download changes from the store? I am concerned that if is not this way I will potentially have to keep all History
0
0
710
Dec ’21
What is the most suitable back-end integration for SwiftUI simple data synchronisation with other users?
Hi, I am designing a simple task manager for a household in SwiftUI. I would like the app to synchronise the content data across the devices of the various users part of the household. To me, this seems like a simple enough process potentially. Which approach is best suitable with the SwiftUI framework? The data model of the app is very simple at the moment; essentially a collection of tasks that each feature a title, description and assignment to a user. Running the app locally, without synchronisation implemented yet, allows me to make use of the SwiftUI's framework declarative programming and elegant design. I realise that to implement synchronisation with other users' devices unavoidably means I need to implement code and adapt existing code. For years, I have browsed articles and tutorials on data sharing in iOS apps. Options I have explored are Core Data, CloudKit, manual API fetching from server and third-party options like Realm. The underlying, unnamed issue seems to be that SwiftUI is still young an
0
0
1.9k
Feb ’21
Customize behavior of NSPersistentCloudKitContainer
I'm working on a SwiftUI app generating data using a standard CoreData data model and sync it with iCloud using NSPersistentCloudKitContainer. In this data model one parent is referencing on many children (e.g. > 2000 of children A and B). Each child A is also referencing onto one child B and vice versa: Parent ----> Child A; Parent ----> Child B; Child A <---> Child B The problem I am facing is, depending on the last time an CloudKit sync has been performed, the sync process takes hours to complete (where in the mean time the app might be sent to the background by the system or by the user and the sync is stopped). Is there a way to efficiently sync these larger datasets? Additionally I would like to pause the iCloud sync for specific occasions e.g. when performing continuous tasks using Background Modes and the app would be killed due to CPU pressure of iCloud sync. Is there a way to customize the syncing behavior of NSPersistentCloudKitContainer like e.g. CKOperation or by
0
0
882
Jun ’21
Accept CKShare with SwiftUI App lifecycle
In iOS 15, macOS 12, tvOS 15 and watchOS 8 we can finally share NSManagedObjects using NSPersistentCloudKitContainer 🎉 I've been playing around with it and I've managed to share an object from one Apple ID to another. But I'm unable to accept the invite. 😰 If I understand the docs correctly I'm supposed to call func acceptShareInvitations(…) with CKShare.Metadata representing the invite. This metadata should be forwarded to my app using either AppDelegate or SceneDelegate. The problem is that I'm using the SwiftUI App-protocol. I tried setting up an UIApplicationDelegateAdaptor with this code: ivar added @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate AppDelegate implemented class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) { assertionFailure() } } The assertionFailure is never called, so my guess is that the SceneDelegate is being called instead. So, how do I im
0
0
876
Jun ’21
Possible to override background push limits during development?
The video discusses limits to background pushes. I'm unable to finish developing my app that uses NSPersistentCloudKitContainer on iOS 14 because I believe background push notifications are being limited by the system so I am unable to test how the app behaves when it is suspended and a background push arrives. In fact I cannot get any background pushes to arrive at all, however pushes do arrive when the app is running in the foreground. Is there perhaps a development entitlement or launch param to override all limits so I can finish my app? And if not, can this feature be added please?
0
0
1.1k
Sep ’20
Core Data: Using local and iCloud
Hi everyone, I'm trying to use in my app core data as persistent storage. In this app it is supposed to have some entities of core data local but also some other synced through iCloud. In the xcdatamodeld, I create two configs that belongs to each type offline(local) and the online(iCloud) but I'm getting a strange error where it says that it can't use the same container name. I don't understand if for each entity I want to be synced on iCloud I need a different container. Also, I do not understand because if I use only iCloud syncing without using any configuration, I can store different entities. Also, if each entity has a 1:1 relationship with the container, why is impossible to delete it, it doesn't make sense. Here is the code I'm using persistentContainer = NSPersistentCloudKitContainer(name: name, managedObjectModel: model) var defaultDirectoryURL: URL var descriptors = [NSPersistentStoreDescription]() for capability in self.dbCapabilities { if capability.cloudEnable { defaultDirectoryURL = NS
0
0
478
Oct ’20