Hello,I'm working on refactoring an existing app to use the new NSPersistentCloudKitContainer.Our app is managing different Projects items which consist of a mix of structured data and files.Files are stored locally and only their path are stored in one core data store at the moment.Enabling NSPersistentCloudKitContainer did the job as now the db syncs between devices as expected.As we would like to segregate each project into its own CoreData store, my question is: Is it possible to leverage NSPersistentCloudKitContainer to sync multiple core data stores within the same app and have all of those stores synced?Can you point me to any documentation that demonstrate this use case?Thanks for the feedback.Best regardsSantiago
Search results for
NSPersistentCloudKitContainer
589 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
HiI try to use the NSBatchInsertRequest. but the insertResult is nil, and my CoreData is emptyI use the viewContext of the NSPersistentCloudKitContainer.let container = NSPersistentCloudKitContainer(name: CoreDataPerformance) container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError(Unresolved error (error), (error.userInfo)) } }) try container.viewContext.setQueryGenerationFrom(.current) let moc = container.viewContext moc.automaticallyMergesChangesFromParent = true moc.perform { let insertRequest = NSBatchInsertRequest(entity: Client.entity(), objects: clients) let insertResult = try? moc.execute(insertRequest) as? NSBatchInsertRequest if let success = insertResult as? Bool { print(RESULT: (success)) } }This is the error I receive in the console.2020-02-04 18:30:25.800705+0200 CoreDataPerformance[62836:778869] [error] warning: Multiple NSEntityDescriptions claim the NSManagedObject subclass 'CoreDataPerformance.Client' so +entity
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
I'm experiencing the same or similar problem.I suspect, but I am not certain, that it is a bug and I'll try to explain my reasons why... but first...My scenario:Xcode 11.3 project developing for iOS 13.x and beginning to implement NSPersistentCloudKitContainer.I have `Transformable` type attributes for two Entities in my data model (for some time now). Incidentally both these attributes are used to store an optional value for Measurement<UnitMass>, which I understand from my reseach, conforms to `Encodable` and is therefore able to just work with a Core Data attribute of type `Transformable`. Others have written more on the capabilities of the Foundation `Measurement` class, using more accurate language than me, in this and other forums, so I'll leave this part of my description short.As I am still in development with my Xcode project, I regularly switch between NSPersistentContainer and NSPersistentCloudKitContainer for testing purposes. This requires regularly resetting the development enviro
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
I've got a few quetsions about designing an acceptable user experience involving migrating from legacy Core Data store to a CloudKit+CoreData store.Given the user can have a legacy data store on all of their devices and only one of those sets of data will be considered supreme, I need a means to effectively merge all this data in a non-destructive way.1) Does NSPersistentCloudKitContainer provide a means of opting into or out of CLoudKit storage for the user? Is it fully reliant on the user going into settings and flipping the iCloud-Data switch? Or can I maintain a local app settings flag? Can I tell a NSPersistentCloudKitContainer to no longer sync during it's lifecycle? 2)
Oh cool, I guess cmd+s is post....2) I'm curious if there's a means to allow the user to choose the version of the data in CloudKit or the version of the data on Device. My data sort of adds up to an expected whole. If one record is added or deleted, then the sum of the records will be incorrect. To give the user a good experience, I'd like to give them the ability to pick a snapshot of two different versions of their entire data set.Can `NSPersistentCloudKitContainer` facilitate this in anyway?3) Is there a best practices guide or design pattern recommendations with recards to UX anywhere?
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
The Apple Demo, which is very thorough, doesn't prune persistent history?And the Forum Thread seems to suggest that persistent history is integral to how NSPersistentCloudKitContainer works.Are we supposed to explicitly prune persistent history ourselves or is it handled for us by NSPersistentCloudKitContainer?Apple Demo: https://developer.apple.com/documentation/coredata/synchronizing_a_local_store_to_the_cloudForum Thread: https://forums.developer.apple.com/message/373336#373336
I'm trying to call CKFetchRecordZoneChangesOperation to get the latest changes from the shared database.But when I run that operation from inside didFinishLaunchingWithOptions, NSPersistentCloudKitContainer will break. It will save to coredata, but it will no longer sync to Cloudkit. It's as if it's paused. When I restart the app, the sync resumes.But if I call CKFetchRecordZoneChangesOperation later in the app lifecycle, say in viewDidLoad, everything works fine. Why is this?
Hello,I have an issue in an app which is yet unreleased.The app uses Core Data, and I recently added CloudKit integration.Whenever I start the app data get automatically downloaded by CloudKit and I get this log: <NSCloudKitMirroringDelegate: 0x600001da61b0> - Never successfully initialized and cannot execute request '<NSCloudKitMirroringImportRequest: 0x6000024c88a0> D3FB21AB-94ED-40B7-859B-6CBEE6149473' due to error: Error Domain=NSCocoaErrorDomain Code=134404 (null) UserInfo={NSDetailedErrors=( Error Domain=NSCocoaErrorDomain Code=133021 (null) UserInfo={NSExceptionOmitCallstacks=true, conflictList=(n NSConstraintConflict (0x600003f40e00) for constraint (n namen): database: 0x8143748c0004e8e1 <x-coredata://272191BB-7D10-41DD-8E4B-56F4ECE4AB9F/Ingredient/p195>, conflictedObjects: (n 0x8143748c181ce8e1 <x-coredata://272191BB-7D10-41DD-8E4B-56F4ECE4AB9F/Ingredient/p1733>n),n NSConstraintConflict (0x600003f42fc0) for constraint (n namen): database: 0x8143748c029ce8e1 <x-coredata://27
I have a model that has already been pushed to production, and I would like to move an attribute to a new entity as a relationship.From This:extension Note { @NSManaged public var drawingData: Data? .... }To This: extension Note { @NSManaged public var drawing: Drawing? .... } extension Drawing { @NSManaged public var drawingData: Data? .... }According to the Apple Docs under the Update your Production Schema section, I will need to migrate to a new CloudKit Container, since we can't delete attributes on production CKRecords.What is the proper workflow to do this?I have come up with the following, but I believe it is wrong.lazy var oldPersistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: Model) let storeLocation = URL(fileURLWithPath: /path/to/cloud.store) let storeDescription = NSPersistentStoreDescription(url: storeLocation) // Set the container options on the cloud store cloudStoreDescription.cloudKitContainerOptions = NSPersistentCloud
So I believe I am overthinking it!lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: Model) let storeLocation = URL(fileURLWithPath: /path/to/cloud.store) let storeDescription = NSPersistentStoreDescription(url: storeLocation) //Set the container options cloudStoreDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: com.myCompany.myApp2) // TODO: Migrate Core Data Store to new Model Version container.loadPersitentStores... ... }()This should be enough to handle the migration from Container 1 to 2, since the data is already stored in Core Data. Then instead of hooking up a persistent container to the old CloudKit container (which would probably throw errors due to mismatched Schema), we can use CloudKit to fetch and confirm all data has already transfered properly, fix missing data, and delete the recrods in Container 1.I decided not to Migrate Containers for this, instead Im using ver
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
Let's suppose I want to provide a new user with some sample data which they can use to familiarize themselves with my app. In the NSPersistentContainer (i.e., local-only) case, I use one-time initialization logic to manually populate my app with this sample data. Then, over time, the user can keep that data, modify it, or delete it, as they choose.Now if I want to do the same thing with NSPersistentCloudKitContainer, this should be fine with my user's first device. But let's further suppose that (after using my app [and changing the CoreData database contents), my user load my app on a second device and runs it. On the second device, it will ALSO build an initial database containing sample data.What happens now? Does the content of the second device superceed the contents of the first? Suppose the user deleted a same record on device 1, but that sample record is loaded onto device 2 (as part of it's one-time initialization). Does that record reappear on device 1? And if a sample record is modified on
I have this problem where your crash originates on the queue:com.apple.xpc.activity.com.apple.cloudkit.scheduler.com.apple.coredata.cloudkit.activity.export (serial)This might be the same problem you are speaking of.I reported it to Apple (no solution yet).But important point is: It seems to happen only in debug mode. I have released an app with NSPersistentCloudKitContainer and it does not crash in production.
Topic:
App & System Services
SubTopic:
General
Tags:
For the past two days I've been trying to figure out how to get the notification when the iCloud data has changed. I use a NSPersistentCloudKitContainer and am able to see my changes from one device in another. I just added local notifications to my app and I save the notification to an iCloud entity whenever a user sets it.Since I'm adding this notification in iCloud, a remote notification with iCloud changes will be sent to the users devices with iCloud enabled. What I would like to do is when the device gets this notification, read from the new data and set a local notification on the current device if a notification entity is found.But I can not seem to figure out how to intercept this change notification. I tried using didReceive and didReceiveRemoteNotification from the AppDelegate, but none of these functions fired when the device received the iCloud changes. In the Xcode console I can see that the device is notified with the data.How can I intercept the background notification that contains t
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 have exactly the same problem, I use NSPersistentCloudKitContainer with Catalyst. The problem started after I deployed the Schema to production.The synchronization works perfectly on all devices (mac, iPhone, Simulator) until I add a photo from Simulator. This photo is synchronized with Mac, but as soon as it tries to sync with iPhone, it crashes. The only way I found not to crash, is to delete as many photos as I had added from Simulator. After that, iPhone crashes stops and starts syncing again.EDIT:I've found that the problem is not from the simulator but from a big image.I tried that using a 8k image and it crashed.If I deselect the Allow External Storage option though, it works fine.
Topic:
App & System Services
SubTopic:
Core OS
Tags: