Core Data with CloudKit uses a specific record zone in the CloudKit private database, which is accessible only to the current user.It's not possible to use CloudKit and CoreData with the CloudKit public database? Here is my scenario.- I have an application with two core data stores.- The first store should be synced with the public CloudKit database and NOT updated by the user.- The second store should be synced with the private CloudKit database and updated by the user.lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: MyAppName) // Create a store description for the first store let firstStoreLocation = URL(fileURLWithPath: /path/to/first.store) let firstStoreDescription = NSPersistentStoreDescription(url: firstStoreLocation) firstStoreDescription.configuration = First // Create a store descpription for the second store let secondtoreLocation = URL(fileURLWithPath: /path/to/second.store) let secondStoreDescription = NSPersiste
Search results for
NSPersistentCloudKitContainer
589 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I believe that yes, it will create two stores and two different containers with private databases. I used to think, incorrectly, that there was a 1 to 1 mapping between an instance of NSPersistentCloudKitContainer, and a single CloudKit store description, but I've come to realize that one instance can handle multiple cloud synced stores.When working with multiple stores, create an instance of NSPersistentCloudKitContainerOptions for each store you wish to use with CloudKit.And no, you can't access the public, or shared database with Core Data for CloudKit. Also, if you want to write to the public database but not as an individual user, you can't do that through the iOS CloudKit API. CloudKit CKRecord instances are always owned by the user who created them. You'd have to use a server to server key and use their REST API from your app. That way you can write records as admin. I was thinking of using the public database to store app configuration data, but I'm not sure I want to develop with yet another
Topic:
App & System Services
SubTopic:
Core OS
Tags:
By the time this debug output is printed, I've loaded 2 store descriptions, into a NSPersistentCloudKitContainer, that both have the NSPersistentCloudKitContainerOptionsKey set, both with differing containerIdentifiers that exist in iCloud. Yet, attempting to initialize the schema fails saying none of my store descriptions in the coordinator are configured to use CloudKit. They definitely are configured in the MOM. Other observations: I'm beginning to think it's not advisable to have 2 configurations in one MOM that both point to different iCloud containers, because Xcode tells me that I have to add entities from one CloudKit configuration into another CloudKit configuration in order to get it to compile. Yet the one configuration contains just a single entity with no relationships at all. So that's really unexpected. Will Core Data attempt to generate CKRecords in both containers for the entities that appear in both CloudKit configurations? Perhaps it's best to use seperate MOMs (and an associated NSPersistentCloudKitContainer
More info: I have experimented with code similar to yours to initialize two CloudKit schemas with one single request on the single NSPersistentCloudKitContainer instance. It does indeed work, however,there are limitations with the Xcode schema designer which render the results, effectively useless. The problems start when you create multiple configurations in your schema model, that are declared to be used with CloudKit. The schema designer has no knowledge of container identifiers, nevermind multiple container identifiers. I discovered that as soon as I added a new CloudKit backed configuration and added a single new entity to it with zero relationships, my project no longer compiled. Xcode told me that I had to add the entities from the other CloudKit backed configuration to this new configuration with it's single isolated entity. Bizarrely, it never instructed me to add the new isolated entity to the previous CloudKit configuration. It was complaining about relationships in the older CloudKit conf
Topic:
App & System Services
SubTopic:
Core OS
Tags:
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
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
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.
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.
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}
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
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
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
I am unfamilar with NSPersistentCloudKitContainerbut I note that the following references the private database:https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer?language=objcA container that encapsulates the Core Data stack in your app and mirrors select persistent stores to a CloudKit private database.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
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
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
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.)
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
Hi,is there a way to ask NSPersistentCloudKitContainer to refresh/look for remote changes manually?While it would be great if push notifications would work in the simulator so syncing can be tested without multiple actual devices it would be helpful to have a way to manually request a refresh.Greetings,Ralf