Hi, I am trying to fetch CKShare for NSManagedObject. Firstly I get CKRecord for it using NSPersistentCloudKitContainer's record(for:) method. And getting situation when: First time record(for:) gives correct CKRecord I successfully create CKShare, see it in online Dashboard Next time record(for:) gives old CKRecord which don't have share yet, it's outdated! I swipe down notification Notification Center or minimise the app (go to home screen), and when go back, database is being immediately updated and record(for:) returns correct CKRecord with existing share now. I can get correct CKRecord if I use only recordID from CKRecord that I get from record(for:), and fetch updated CKRecord using fetch(withRecordID:completionHandler:). But it increase awaiting time twice because I need to get response for correct CKRecord and then fetch CKShare for it. If no share for CKRecord, I could get that nil immediately but now I have to fetch correct updated CKRecord. So, anyone know how to keep local database update
Search results for
NSPersistentCloudKitContainer
589 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am using NSPersistentCloudKitContainer. All data sync in iCloud. And when uninstalled the app, its sync correctly. However, it's required to encrypt sensitive data. I made my password attribute Transformable. Thus work fine locally. However when I delete the app. Install again. All other attributes(String, Int) sync correctly but transformable attribute does not export/synced.Here is my Modelhttps://i.stack.imgur.com/emA4m.pngpublic class EmployeeEntity: NSManagedObject { @NSManaged public var password: NSObject? @NSManaged public var firstName: String? @NSManaged public var lastName: String? @NSManaged public var idNumber: String? @NSManaged public var modifiedDate: Date? @NSManaged public var password: String? @NSManaged public var title: String? static var entityName: String { return EmployeeEntity }}extension EmployeeEntity { static func getListItemFetchRequest() -> NSFetchRequest<EmployeeEntity>{ let request = EmployeeEntity.fetchRequest() as! NSFetchRequest<EmployeeEntity> requ
I'm attempting to use Core Data + CloudKit to persist user's data with the NSPersistentCloudKitContainer class. I'm able to see created records in the Development environment but records won't show in the Production environment. With just this brief description, what could be the issue? Notes I have deployed the schema to the Production environment. I'm using the same device and iCloud account for both environments My Apple ID is the same for my personal and dev account. I'm attempting to add records to Production via a TestFlight build The iCloud toggle for the app is ON. What are some initial thoughts as to why there is a sync issue?
I am using the following to initialize my PersistenCloudKitContainer with the goal of loading a shared poblic cloudKit database: container = NSPersistentCloudKitContainer(name: FaceExplorer) guard let description = container.persistentStoreDescriptions.first else { print(Can't set description) fatalError(Error) } //ios 14 bug fix https://developer.apple.com/forums/thread/682925 description.cloudKitContainerOptions?.setValue(1, forKey: databaseScope) // normal / ios 15 version description.cloudKitContainerOptions?.databaseScope = .public //seems to work & Load on iOS14.5 description.cloudKitContainerOptions?.setValue(iCloud.com.myDomain.myContainerID, forKey: containerIdentifier) container.loadPersistentStores(completionHandler: { (storeDescription, error) in ... This all works great on iOS14 and also loads on iOS15.0 - 15.2 with users logged into iCloud with the iCloud drive option checked. However, when the iCloud drive option is not checked on iOS15 only, the container will not load. Please hel
I use NSPersistentCloudKitContainer to synchronize data between iOS and macOS. After installing the app, it takes long (sometimes up to an hour) for all data to become available. Related to this, I have a few questions: Synchronization seems only to take place when the app runs in the foreground. Is there a way to keep the app synchronizing when it is brought to the background? I have enabled remote notifications and use registerForRemoteNotifications in my app delegate (via UIApplicationDelegateAdaptor). I haven't yet experimented with background processing. Should I do that, and can you point me to some references? Is there a way to check whether the local-stored data matches what's available on the server? E.g. checking whether a (local-stored) NSPersistentHistoryToken matches the latest NSPersistentHistoryToken on the server. Internally NSPersistentCloudKitContainer knows, as I can see log events popping up saying that there are no new data to mirror. I would like to know this to inform
I have a Multiplatform app for iOS and macOS targets written 100% SwiftUI. I'd prefer to keep it that way, although will consider view representable options. Its a Core Data driven app, also implementing NSPersistentCloudKitContainer, I have a three column view, the first a List with style .sidebar, the second a List of items for an Entity in my Core Data model object graph, the third a detail view for the selected item in the second column List. I have begun to implement @SceneStorage to persist selected rows/cells in the lists (and sidebar), which works very well. However, if a selected row or cell is half way down the list => off screen, then the user cannot see the selection and for some reason the detail view does not show the details of the selected item, until the user manually scrolls down to the item in the list. When the selected item is revealed on screen via the manual scroll action, it is shown as selected item in the list and the detail data is only then populated. I want to be able
I'm trying to create a note-taking like app that uses NSPersistentCloudKitContainer and core data. The store uses the NSMergeByPropertyObjectTrumpMergePolicy, which is fine for almost every property. For example, if the name of a file is changed on two different devices, then it's fine to use the latest value. The problem is that the note text cannot be overridden by the latest value if it's changed on two devices at once. It needs to be detected as a conflict so the user can choose which version they want to keep. I can replicate the behavior by turning off wifi on one device and writing content, then writing content on a different device at the same time. When I turn the wifi back on, whichever device saved the changes last completely overrides the other device's text. What I'd like to accomplish is detect when there is a conflict of text, then create a duplicate file called Conflicted Copy. Bonus points if someone can tell me how Apple Notes magically merges text without ever creating a conflict.
After upgrading to iOS 18, my Core Data stack using NSPersistentCloudKitContainer in a shared App Group container stopped syncing correctly. The persistent store configuration, which previously worked in iOS 17, now experiences delayed or missing sync updates between devices. Then the app freezes and writes terminal the same error detail (which I provided) too many times. The debug logs from the CloudKit mirroring delegate (NSCloudKitMirroringDelegate) show repetitive notifications but no updates in persistent history. Additionally, the persistent history tracking key appears unresponsive to local changes, causing transactions to fail in updating or syncing as expected. Key setup details: Core Data is set up within an App Group container using NSPersistentCloudKitContainer. NSPersistentHistoryTrackingKey and NSPersistentStoreRemoteChangeNotificationPostOptionKey options are set to true. Any insights into changes in iOS 18 Core Data or CloudKit handling with NSPersistentCloudKitContainer
I'm using Core Data and CloudKit together, and so far everything looks great. But one thing that I haven't been able to find much literature on is the interaction between NSPersistentCloudKitContainer and Persistent History Tracking. My assumption is that NSPersistentCloudKitContainer leans on Persistent History Tracking to execute its responsibilities. So if we're using Persistent History Tracking elsewhere – maybe to update an app extension using a process similar to the one outlined at https://www.avanderlee.com/swift/persistent-history-tracking-core-data/ – there's a risk of interrupting that process. Especially with regards to executing a NSPersistentHistoryChangeRequest.deleteHistory(before:) request. Would this run the risk of deleting history that NSPersistentCloudKitContainer requires to perform its roles? Is there a way to synchronise these various responsibilities?
I'm looking for a solution for the next situation: My app uses CoreData with CloudKit mirroring (via NSPersistentCloudKitContainer). In the latest version of my app I made some changes in db schema and created heavyweight core data migration for it. After this migration finishes, I see lots of duplicates for my entities. I think that CloudKit sees migrated container as a completely new one and just tries to download everything from iCloud again. So generally the question is: should I clean my old CloudKit container somehow and just copy all the data from the new, migrated local one, or there is another solution, how to update cloud kit data with new migrated entities? I'm sorry, if this question is stupid, I'm new to cloud kit and used it in totally auto mode, by just replacing NSPersistentContainer with NSPersistentCloudKitContainer (please, see the code here - https://gist.github.com/eiskrenkov/228c6ecb5c1b78ba360838114a7d0911 ), but now this issue happened. Any help, or chunk of code will
Am I wrong or is it not possible to share Core Data+CloudKit with a keyboard extension? It works if I set an app group but then I lose the CloudKit sync feature, which is not acceptable for me. Is there some other way to share the data while keeping sync?
Trying to figure out the best way to update an CoreData app to use Cloud Kit.Right now I have a ObjectA entity defined as the top level object. There is a Photo entity that contains a Binary Data attribute for the thumbnail and a URI for the location of the full image. So bascially that setup is a lot like a CKAsset in CloudKit and CKAsset would seem to be the logical way to get the images to sync between devices.I can't find anything along those lines relating to NSPersistentCloudKitContainer though. As the model is taken from Core Data model you can't really predefine an asset attribute. So would the approach be to get the CKRecord and directly add the CKAsset that way? Would there be repercussions related to the Container if you did that?And if there is some simpler way I am missing please let me know. I am aware I can do a Binary Data attribute, I had done that earlier in the app's life and it didn't work as well as just providing the URI for the image and managing the data myself. Or would that
My app backup the data to iCloud or sync with user device through the user iCloud account using NSPersistentCloudKitContainer privateDataBase. The main problem is, when user install the app I need to know if user has data in iCloud or not according this information, I let user to setup account or fetch the existing account, since it takes too long to fetch with local CoreData, I am trying to find a way to fetch directly from iCloud through CloudKit, since I am new in CloudKit, I don't know how to fetch data from CloudKit any help appreciate.
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!
The presenter says you might be wondering why we don't do this with CKReference instead. And that's because CKReference has some limitations that we don't think work well for Core Data clients. Namely that it's limited to 750 total objects. However, that isn't correct, the 750 limit is only for references that have a delete action: https://developer.apple.com/documentation/cloudkit/ckrecord/reference Important There is a hard limit to the number of references with a CKRecord.ReferenceAction.deleteSelf action that any one record can have. This limit is 750 references, and any attempt to exceed it results in an error from the server. This is why the Notes app has no issue with more than 750 note records with a reference to a folder record. I really wish NSPersistentCloudKitContainer had used CKReference and also that _CKReferenceActionValidate was made public. CKShare has limitations too, yet it used that and there was no custom sharing done like custom references were done.