Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

CloudKit - initializeCloudKitSchema error
Hi, I've previously used a local core data database successfully with my app and now I wanted to use NSPersistentCloudKitContainer to store the data in CloudKit. However when I do container.initializeCloudKitSchema(options: []) I receive an error which I'm not able to comprehend: CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _requestAbortedNotInitialized:](2112): - Never successfully initialized and cannot execute request ' 17E8940B-00D6-4D01-AA78-6A04EBEBC957' due to error: ... 9 Batch Request Failed CKError's omited ... }> I also get this error in the console: Atomic failure = I've tried to reset Reset Environment in the CloudKit dashboard to no avail.
1
0
1.1k
Apr ’23
NSPersistentCloudKitContainer/Core Data design approach
I'm using NSPersistentCloudKitContainer together with a private and public database. I have a public database with articles. Users should be able to like an article but I'm wondering what would be the best design approach to achieve this. The users can also add articles that they find online which are then automatically liked for the user adding it (and uploaded to the public database) Question 1 I want you to be able to see how many people have liked an article, so I think there will perhaps be an array on the article with the userId who liked it and then you just do a count on it? Or do you think there is a better way? Question 2 I am thinking about how the liked article should be saved for the user, either put that article in their private database, but then that article will be disconnected from the public article. Or I can filter out among the public articles that contain the user's userId (however, I'm a little unsure how it works in practice as the public database is polled every 30 minutes wi
0
0
846
May ’23
Core Data + CloudKit crash on startup only in production
Hi, My macOS app's production build is crashing on start with an unhelpful crashdump. In the console, the only error in the Console is BUG IN CLIENT OF CLOUDKIT: Not entitled to listen to push notifications. Please add the 'com.apple.private.aps-connection-initiate' entitlement. Adding this entitlement to my entitlements.plist breaks the app entirely (Unsatisfied entitlements). Here is how I'm loading my persisten store: lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: ChatModel) guard let description = container.persistentStoreDescriptions.first else { fatalError(###(#function): Failed to retrieve a persistent store description.) } if(UserDefaults.standard.bool(forKey: StoredPreferenceKey.iCloudSync)){ description.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: iCloud.XXXXX) } else { description.cloudKitContainerOptions = nil } description.setOption(true as NSNumber, forKey: NSPersistentH
2
0
955
May ’23
Field '___modTime' is not marked sortable
I'm using NSPersistentCloudKitContainer and I'm getting warnings in the console saying: CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedExportWithLabel:activity:completionHandler:]_block_invoke(3457): - Finished automatic export - AppActivationExport - with result: storeIdentifier: F2C60E7A-CEC4-44F2-B467-7324C065AD33 success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134406 Request '1FA53D40-43FB-4751-8719-0D26393D5301' was aborted because the mirroring delegate never successfully initialized due to error: UserInfo={NSLocalizedFailureReason=Request '1FA53D40-43FB-4751-8719-0D26393D5301' was aborted because the mirroring delegate never successfully initialized due to error: } I have added indexes for recordName and modifiedTimestamp to all my records as queryable as per the instructions.
2
0
1k
May ’23
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
Can a private database entity have a relationship to a public database entity?
I’m using NSPersistentCloudKitContainer and I’m utilising the public database and also the user’s private database. For example I have an entity called Category which has a many-to-many relationship to an entity called NewsArticle. So the NewsArticles exist in the public database for the user to browse, but he can add them to a category which will live in his private database. So that’s my question, is it possible for an entity which exists a in the private database to have a relationship to another entity in a public database?
1
0
959
May ’23
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
How to sync NSPersistentCloudKitContainer in background after performing AppIntent from widget
I have an app that uses NSPersistentCloudKitContainer and a widget that displays a record. I want to add a button with interactive widgets in iOS 17 to modify the visible record via an AppIntent. When I do this the app logs: CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate managedObjectContextSaved:](2945): : Observed context save: - It does not automatically sync this change to iCloud, not until I manually return the app to the foreground, even if I delay returning from the perform() function. Is there a way to sync NSPersistentCloudKitContainer while the app is in the background as a result of this change triggered in the widget? Thanks!
2
0
909
Jul ’23
CoreData data disappears locally after disabling iCloud in device Settings
I've built an app and got it working nicely with CoreData, and now I want to integrate it with CloudKit. I have made some minor changes to my code (namely updating NSPersistentContainer to NSPersistentCloudKitContainer and CloudKit works - I can see records appearing in the iCloud dashboard and I can modify records from the iCloud dashboard and the changes reflect on my device. Great. However, if I disable iCloud syncing via Settings on my device (without force-quitting my app) I notice a couple of things: When switching back to my app if I try and edit an entity I sometimes get an app crash If I quit and reload the app all my data has disappeared from my device (it still remains in iCloud). Is this expected behaviour? Ideally, what I would like, is that the data persists locally if a user has added records but then later decides to disable iCloud syncing on the app. Here's my code in case I've done anything funky with the implantation. It feels pretty simple, but maybe that's the problem. CoreDataMa
1
0
752
Jul ’23
NSPersistentCloudKitContainer CKRecord conversion errors
I'm using NSPersistentCloudKitContainer with my app and everything has been working fine for the most part. However, every now and then I come across an entity that saves fine into core data but then can't sync to cloud kit and causes the entire cloud kit feature to stop working. The error happens when starting the app and looks like this: error: CoreData+CloudKit: -NSCloudKitMirroringDelegate _requestAbortedNotInitialized:: - Never successfully initialized and cannot execute request ' 3CD51F2A-E632-4FF0-8B8C-C17DCB15A002' due to error: ... 3 Batch Request Failed CKError's omited ... }> The app is for keeping track of Books, so the basic data model is an entity named Book with a relationship named imageData. This maps to an entity named ImageData with a field named data. data is of type binary data and where the cover image for a particular book is stored. This has worked so far for hundreds of entries into core data and cloud kit, but every now and then I see an error like this in the console a
4
0
1.3k
Jul ’23
Reply to NSPersistentCloudKitContainer CKRecord conversion errors
@CrunchyBagel Thank you! That is also helpful. I wasn't aware that initializeCloudKitSchema() was different than just manually promoting from development to production after creating test records within the App but I see what you mean now. I thought that NSPersistentCloudKitContainer created all necessary records in the development environment based on whatever is defined inxcdatamodeld as part of how it works and you then later promote those to production. I see it only creates records based on the specific data that has been uploaded which isn't going to include optional _ckAsset records and other things unless those were specifically needed for the test data. Again, much appreciated!
Jul ’23
Potential problem with synching users' private CloudKit with NSPersistentCloudKitContainer
Imagine I have a game with new levels every day. Users play my game and their progress is saved in Core Data, which is then synchronized with CloudKit via NSPersistentCloudKitContainer. Users' progress is about 500Kb for each level/day. That's 5 Mb in 10 days. Or 182 Mb in a year. If the user plays my game for a year, gets a new iPhone, and installs my app again — will the NSPersistentCloudKitContainer eventually download all 182 Mb of users' data!?
1
0
702
Jul ’23
Reply to Potential problem with synching users' private CloudKit with NSPersistentCloudKitContainer
Yes. the current design of NSPersistentCloudKitContainer is to sync everything. There are other sync engines available between CoreData and CloudKit, such as CKSyncEngine in iOS 17, and open source sun engines like CloudCore, which might provide more fine-grain control over sync. And of course, you can always write your own that best suits your needs.
Jul ’23
cannot push coredata records to cloudkit
coredata pushed schema to cloudkit only for those entities for which I created records. But the record data did not get pushed. I set recordName as Queryable and modifiedTimestamp as both Queryable and sortable. Query does not show the records. I look at Xcode console gives this output for one of the entities that got pushed to cloudkit : CoreData: debug: CoreData+CloudKit: -[PFCloudKitSerializer newCKRecordsFromObject:fullyMaterializeRecords:includeRelationships:error:](575): Serializer has finished creating record: , Also schema for some other entities that do not have any core data records did not get pushed to CloudKit. I thought the entire coredata schema should get pushed along with the records. Looks like it is pushing those entities that have some records but without pushing data. I reset the cloudkit environment and tried again, but issue is not resolved. Also the AppDelegate never gets called. I thought the line below should have called AppDelegate @UIApplicationDelegateAdaptor(AppDelegate.self) var
2
0
1.2k
Aug ’23
Can I access CloudKit's metadata fields with NSPersistentCloudKitContainer?
I've got a simple Core Data Entity that is synchronized with CloudKit via NSPersistentCloudKitContainer. I can read my local fields, but how can I read fields like Created & Modified from CloudKit? Do I have to add them to my Core Data model and populate them myself? P.S. In his fantastic WWDC talk Using Core Data with CloudKit, at around 21:40, Nick Gillet talks about how Core Data entities in the CloudKit store are prefixed with CD_ to separate the things that it manages from the ones CloudKit implements. Then he says: You wouldn't believe how many people add modify date to their CKRecord. Like it's something redundant.
0
0
633
Aug ’23