Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

Reply to How to fix NSCloudKitMirroringDelegate unhandled exception after faulty model change
One root cause that we have identified for this issue is removing a many-to-many relationship from your model. This is supposed to be a supported migration, so we are collecting feedback reports to track against that as a bug. If you would like to be notified of a fix for that share your feedback number here and we can relate them together. As a workaround you can simply add the relationship back. Or, attempt a more detailed / invasive solution described below. Our schema is public and described here: https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/reading_cloudkit_records_for_core_data Your container will contain CDMR records that identify the offending relationship. The fields CD_entityNames and CD_relationships can be used to tell which relationship a record represents. One (or more, depending on how many relationships you removed) of those records may be causing this issue. You can choose to: Add the missing relationship back to your model Delete the offending
Oct ’23
CloudKit not working properly in iOS 17 RC
CloudKit was working perfectly in iOS 16. However after updating to iOS 17 RC on my devices iCloud sync no longer works properly. The app has a package called CloudKitSyncMonitor which shows the sync status. Normally it would say Synced with iCloud but on iOS 17 it is either stuck in the Syncing or Sync not started state and the data doesn’t update. This mostly happens after a reinstall of the app. After some time it randomly decides to work until I uninstall the app. I’m really confused what could be the problem if it was working fine on iOS 16 but barely works properly on iOS 17? This is currently the code I have for the DataController: import SwiftUI import CoreData class DataController { var container: NSPersistentCloudKitContainer @AppStorage(wrappedValue:true,syncEnabled,store:UserDefaults(suiteName: group.com.ip18.SubManager)) var syncEnabled static let shared = DataController() init() { container = NSPersistentCloudKitContainer(name: Subscriptions) load(syncEnabled: syncEnabled) } fu
4
0
2k
Oct ’23
How to deduplicate entities with relationships in NSPersistentCloudKitContainer?
In my app I have a defaultJournal: Journal, that automatically gets added on the user's device on launch. There should only be one default journal, and I know that deduplication as shown in the Apple Demo, is the correct approach to ensure this on multiple devices. Journal looks something like: class Journal: NSManagedObject { @NSManaged var isDefaultJournal: Bool @NSManaged var entries: Set? } Since Journal has a relationship to entries, how can I deduplicate it ensuring that I don't orphan or delete the entries? I am worried that the entries aren't guaranteed to be synced, when we discover a duplicate journal in processPersistentHistory. This would lead to either orphaned or deleted entries depending on the deletion rule. How can one handle deduplicating entities with relationships? For example here is my remove function: func remove(duplicateDefaultCalendarNotes: [Journal], winner: Journal, on context: NSManagedObjectContext) { duplicateDefaultCalendarNotes.forEach { journal in defer { context.delete(journ
1
0
1.2k
Sep ’23
[NSPersistentCloudKitContainer] CloudKit integration forbids renaming 'OldEntityName' to 'NewEntityName'. Older devices can't process the new records. How to proceed?
I used a renaming identifier to rename an Entity Name, but it doesn't seem to work and it causes a crash at start during in-place migration. How to rename an Entity Name when using NSPersistentCloudKitContainer? I get this exception at start: CloudKit integration forbids renaming 'OldEntityName' to 'NewEntityName'. Older devices can't process the new records. Unresolved error Error Domain=NSCocoaErrorDomain Code=134110 An error occurred during persistent store migration. App is not in production, need a way to rename 'OldEntityName' to 'NewEntityName'. How to achieve this?
1
0
916
Sep ’23
Initial sync of watchOS app using Core Data and CloudKit
I have an existing iOS/watchOS app that uses a third-party database and WatchConnectivity. For various reasons I am migrating the app to use Core Data with CloudKit. I have everything working using NSPersistentCloudKitContainer. Sync between the iOS and watchOS app are working on my test devices when I start with an empty database. However, I need to import existing user's data when they first install this new version. Some users may have hundreds or thousands of records, but the total database size is under 1-2MB. Data migration/import is working on the iOS side, the Core Data entities are populated on first launch and uploaded to CloudKit (I see in the debug logs that a NSPersistentCloudKitContainer.Event export ends successfully). The problem is launching the watchOS app does not sync the data from CloudKit. I see a import started event but never see it end. I never see any Core Data entities appear on watchOS even after waiting several minutes and re-opening the Watch app multiple times. New enti
3
0
1.1k
Sep ’23
Reply to How does the Reminders app implement manual sort order?
It's hard to tell if Apple uses Core Data and CloudKit, but my guess is that they do. I'm not really sure what you mean by reordering items but I can tell you that using Core Data and CloudKit is very straightforward, just search for NSPersistentCloudKitContainer for using CloudKit and for Core Data I highly recommend you to watch the following tutorials; they're great. Swiftful Thinking: https://www.youtube.com/watch?v=BPQkpxtgalY
Aug ’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
"This NSPersistentStoreCoordinator has no persistent stores", despite setting up all capabilities
Hi guys, First of all, I'm sorry if this is the wrong place to post this. I'm in the last steps of my task manager app: getting the tasks to sync between devices. However, I get the error This NSPersistentStoreCoordinator has no persistent stores (unknown). It cannot perform a save operation. What does this error exactly mean? My container is initialised so it should have a persistent store, right? I've also enabled all the proper capabilities I'm pretty sure (eg, I've enabled CloudKit, created a container, enabled background fetch and remote notifications.) Here is the code for my data controller: import CoreData import Foundation class DataController: ObservableObject { let container = NSPersistentCloudKitContainer(name: TaskDataModel) init() { guard let description = container.persistentStoreDescriptions.first else { fatalError(Container descriptions not loaded) } description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) container.viewContext.mergePolicy = NSMergeByPropertyOb
1
0
2.0k
Aug ’23
Reply to "This NSPersistentStoreCoordinator has no persistent stores", despite setting up all capabilities
I get the error This NSPersistentStoreCoordinator has no persistent stores (unknown). It cannot perform a save operation. What does this error exactly mean? The error message says the persistent store coordinator has no persistent stores. Core Data saves data to a persistent store. If there are no persistent stores, Core Data cannot save your app's data. My container is initialised so it should have a persistent store, right? Are you sure the container was initialized correctly? let container = NSPersistentCloudKitContainer(name: TaskDataModel) Do you have a CloudKit container named TaskDataModel? Set a breakpoint at the start of the init function in DataController. Does the container property have the value you expect? Step through the code line by line. Does the call to loadPersistentStores run correctly or does it generate an error?
Aug ’23
CoreData: warning: CoreData+CloudKit
I use NSPersistentCloudKitContainer. It seems that it the data synced in iCloud after a few seconds. However, I get the following warnings in the console. I do not understand what is it for. CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(813): <NSCloudKitMirroringDelegate: 0x280b051e0>: Successfully set up CloudKit integration for store: <NSSQLCore: 0x280024a00> (URL: file:///private/var/mobile/Containers/Shared/AppGroup/89D9D17C-03DF-48E4-83C3-DB23A8FE0D6F/TestData.sqlite) CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndScheduleImportIfNecessary:]_block_invoke(2033): <NSCloudKitMirroringDelegate: 0x280b051e0>: Scheduling automated import with activity: Could you please explain what is this warning for and what should I do to fix it?
2
0
1.8k
Aug ’23
CD4CK: Can't find Default configuration in M.O.M.
There are a few things about how Core Data 4 Cloud Kit initializes that I'm stuggling to understand. I've spent most of the day finally getting a schema initialized on the server, and learnt a few things along the way.Firstly, even though I have a Default configuration in my managed object model, and it has been there from day one with the option Used with CloudKit checked for true, if I create an `NSPersistentStoreDescription` and set the configuration property to Default, when I try to load the stores, it will fail, saying Unable to find a configuration named 'Default' in the specified managed object model.. If I inpsect the debug description for my ManagedObjectModel instance, it does indeed not have any reference to the string Default in it (I'm not sure if debugDescription is actually printing out the configuration names however). Why does this fail? I can only get my store loaded and the schema initialized if I remove the code that sets the configuration name to Default.The next thing that tripped me up
2
0
1.7k
Aug ’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
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
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