Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

NSSecureUnarchiveFromData is now necessary for transformable attributes but does not work with Core Data CloudKit?
On iOS 13 for transformable attributes that have no custom Transformer class set this appears in the console:One or more models in this application are using transformable properties with transformer names that are either unset, or set to NSKeyedUnarchiveFromDataTransformerName. Please switch to using NSSecureUnarchiveFromData or a subclass of NSSecureUnarchiveFromDataTransformer instead. At some point, Core Data will default to using NSSecureUnarchiveFromData when nil is specified, and transformable properties containing classes that do not support NSSecureCoding will become unreadable.This message appears on devices, in the simulator on High Sierra it even leads to a crash.However, setting the transformer class to NSSecureUnarchiveFromDataTransformer when using CoreData CloudKit, this crashes and leads to Core Data not being initialized.Disabling CloudKit, e.g. setting the .cloudKitContainerOptions on the store description to nil fixes this crash.It seems CoreData CloudKit does not support NSSecureCoding tr
11
0
15k
Sep ’19
Reply to Toggle sync with NSPersistentCloudKitContainer
What worked for me was setting cloudKitContainerOptions = nil before calling container.loadPersistentStores lazy var persistentContainer: NSPersistentContainer = { . . . if !UserDefaultsManager.shared.syncWithCloudKit { container.persistentStoreDescriptions.forEach { $0.cloudKitContainerOptions = nil } } container.loadPersistentStores( completionHandler: { (_, error) in ... } )This is a hack since this works only when persistentContainer is first initialized.Trying to do this after persistentContainer is initialized would require that I safely teardown and reinitialize the CoreDataStack. Reinitializing CoreDataStack creates a new managedObjectContext which then must be passed down the view hierarchy and to any services or managers that cache the managedObjectContext.There are many reasons to want to toggle or pause syncing with CloudKit, and since NSPersistentCloudKitContainer is privy to all the inner workings of syncing with CloudKit, NSPersistentCloudKitContainer should be the one to hand
Sep ’19
Reply to Toggle sync with NSPersistentCloudKitContainer
Did you get this to work? I have a similar need, that is, to offer iCloud storage and sync as a premium feature. I have CloudKit sync working but how do I switch it off? I want to disable CloudKit sync and only enable it when a customer pays for the premium version. I've tried setting the container's cloudKitContainerOptions property to nil but CloudKit sync still happens.Here's my Core Data stack:private lazy var persistentContainer: NSPersistentContainer = { let container = NSPersistentCloudKitContainer(name: modelName) let localDescription = NSPersistentStoreDescription(url: configurationsURL.appendingPathComponent(local.sqlite, isDirectory: false)) localDescription.configuration = Local let cloudDescription = NSPersistentStoreDescription(url: configurationsURL.appendingPathComponent(cloud.sqlite, isDirectory: false)) cloudDescription.configuration = Cloud cloudDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: cloudKitContainerIdentifier) cloudDescrip
Sep ’19
CoreData with CloudKit on watchOS
Hello,I have managed to get CoreData with CloudKit working with the new NSPersistentCloudKitContainer on the iOS version of my app and got it to automatically sync while the app is running. However, when I went to set things up on the watchOS app, I noticed that a sync will only occur if I force close and reopen the watch app.The following scenarios workUser has both the watchOS app and iOS app runningUser makes a change to the data on the watch appThe change is reflected on the iOS appUser has only the iOS app runningUser makes a change to the data on the iOS appThe user opens the watchOS app from terminatedThe changes are reflected on the watchOS appThe following scenario does not workUser has the watchOS app running and the iOS app runningUser makes a change to the data on the iOS appNo change every makes it through to the watchOS app, even after waiting a long timeOnly if I force close the app and restart does a sync occurIn the cases were a sync is successful I see the following logs correctly:C
3
0
1.7k
Sep ’19
Cloudkit and CoreData Sync memory issue with image Data.
I have created a core data model in which i add images of binary data type with Allow external storage. I Sync it on iCloud with Cloudkit using NSPersistentCloudKitContainer. When it automatically sync it from cloud to other device or i uninstall the app and re install it. I have a memory crash as follow.<NSSQLSaveChangesRequestContext: 0x281ec8420> , *** NSAllocateMemoryPages(28317598) failed with userInfo of (null)Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** NSAllocateMemoryPages(28317598) failedI got this crash after updating to iOS 13.1 beta 2. I don't get this crash on simulator iOS 13.0 (It sync it succeccfully from cloud in simulator.)
1
0
1.2k
Sep ’19
Reply to CD4CK Syncing after long-term usage concerns
If I'm reading between the lines, after looking at Persistent History Tracking, I think the content will be downloaded in the order it was created. Although the single article, Consuming Relevent Store Changes, I read in the developer docs assumes some familiarity with the technology, which I have none, it doesn't actually mention iCloud or CloudKit. I still have to watch the WWDC video that introduces Persistent History Tracking, so I'm hoping What's New in Core Data 2017, answers a lot of questions, (although I don't have my hopes up considering it's pre-Core Data for CloudKit), because the Persistent History section in the documentation, is just an API reference with zero actual explanation of the technology. When I said my data model represents something like the macOS file system, I was implying it was an analogy. My app doesn't really have concrete directories or files. It's the tree structure I was trying to explain.My situation is slighly more complex than you might imagine, because of the seed data I
Sep ’19
CD4CK confusion around the new CloudKit Dashboard
TL;DR - the data created in the CoreDataCloudKitDemo WWDC sample app can't be fetched in the CloudKit Dashboard. What is missing from the docs/WWDC talk to make this queryable in the Dashboard?---------------------------First time CloudKit integrater here, so I may be having a problem that's obvious to others but not so much to myself. I'm having a tough time trying to figure out the missing pieces of how to integrate Core Data with CloudKit, given in this fantastic talk WWDC19 here. The only thing missing from the talk was a demo on the CloudKit Dashboard - which is an important thing to leave out, because it's completely changed!I've downloaded the CoreDataCloudKitDemo sample code, and have logged into iCloud on the simulator and set up a container in the dashboard with the same bundle id as the sample code app.When I run it, it sets up the schema on CloudKit Dashboard as expected. This is verified when I created a post in the app on the simulator, a record type of CD_Post is in the CloudKit Dashboard. That
1
0
947
Sep ’19
Ambiguity around the new CloudKit Dashboard
Ok, I'm having a tough time trying to figure out the missing pieces of how to integrate Core Data with CloudKit, given in this fantastic talk WWDC19 here. The only thing missing from the talk was a demo on the CloudKit Dashboard - which is an important thing to leave out, because it's completely changed!I've downloaded the CoreDataCloudKitDemo sample code, and have logged into iCloud on the simulator and set up a container in the dashboard with the same bundle id as the sample code app.When I run it, it sets up the schema on CloudKit Dashboard as expected. This is verified when I created a post in the app on the simulator, a record type of CD_Post is in the CloudKit Dashboard. That's fine, check.What it doesn't do though is upload the data. I'm just trying to verify if the data is in CloudKit Dashboard, yet when I do a query on CD_Post I get 0 results. I'm trying on the public database, but I've also tried on the private and shared database with the same results.On that note, I'm also confused about how to ac
3
0
1.4k
Sep ’19
Reply to Toggle sync with NSPersistentCloudKitContainer
How do you set the store description to nil.....I see its key/value but I tried to set it on the description after loading the store and it says its read only? // MARK: - Core Data stack lazy var persistentContainer: NSPersistentCloudKitContainer = { /* The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail. */ let container = NSPersistentCloudKitContainer(name: name) container.loadPersistentStores(completionHandler: { (storeDescription, error) in {tried to set it here storeDescription.options = nil}
Sep ’19
Can you call loadPersistentStores multiple times?
I have a MOM that has multiple configurations. One configuration is for Core Data for CloudKit, and another is for a local store. There are no relationships between the entities in the local configration and the cloudkit configuration, so practically I could load my local store into a seperate NSPersistentContainer, if I moved my local configuration to a new MOM. However, is it possible to delay the loading of some stores in a MOM? The more I think about it, the less feasable it probably is. At present all stores are loaded into an NSPersistentCloudKitContainer in one shot, but I would like to just set the local store description on the container, and perform loadPersistentStores. Once my app is in a specific state, I would like to add the cloudkit store description to the container's list of persistent store descriptions and then call loadPersistentStores again, hoping that the container would load the cloudkit configuration's newly added store description, and not attempt to reload the local store.
0
0
688
Aug ’19
CD4CK Sample App Availability?
In the 2019 WWDC sessiom 202 Using Core Data With CloudKit it was mentioned...“we're also introducing a new sample application this year that's designed to give you something to hold in your hands, to feel how NSPersistentCloudKitContainer works along with all these other features of Core Data.”Does anyone know if that's available yet, and if so, where to find it? Or even when it might be available? Thanks.
1
0
547
Aug ’19
Reply to CD4CK wont initialize CloudKit schema
OK so it turns out that setting my store descriptions to be added asyncrounsly was the issue. I was hoping it would parallelize the adding of multiple stores within a larger synchronous operation, but the implications are wider. The entire loadPersistentStores method becomes asynchronous, in my experience.It did create two scemas. One in each iCloud container. The problem is that schema designer, isn't capable of supporting multiple iCloud container configurations. And that makes sense because there is nowhere in the schema designer to set the iCloud container IDs. So it will simply complain that CloudKit backed configurations need to have the same entities in them. You'll see a lot of errors like this...xcdatamodel: error: CloudKit Integration: Container.children destination entity ContainerRelation is missing from these configurations: Appture, CloudDataKit.Both configurations Appture, and CloudDataKit have CloudKit enabled for each, and each only has a single entity in it, with zero relations.So it's proba
Aug ’19