1 Reply
      Latest reply on Sep 10, 2019 2:53 AM by alienspaces
      mikepost Level 1 Level 1 (0 points)

        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'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 actually specify within code whether to use the public database. In the previous CKContainer you could access either the publicCloudDatabase or privateCloudDatabase attributes. But in the new NSPersistentCloudKitContainer, which is completely uninherited and unrelated to the CKContainer, it doesn't seem to have any ability to reference or set whether you're using public or private databases.

         

        I've waited until near the end of the Xcode beta release, because I thought that incomplete functionality might be taken care of before release. But I'm now concerned about the lack of documentation in how to actually use Core Data with the CloudKit Dashboard, I don't see how anyone is supposed to create an app using this framework ahead of the iOS 13 release.

        • Re: CD4CK confusion around the new CloudKit Dashboard
          alienspaces Level 1 Level 1 (10 points)

          Hi Mike,

           

          Firstly, CD4CK only supports private databases. It's stated in the subtitle of the article Mirroring a Core Data Store with CloudKit.

           

          Secondly, CD4CK creates a custom zone called com.apple.coredata.cloudkit.zone. If you've been querying the _defaultZone, then you can expect to find nothing for your queries. You need to select the com.apple.coredata.cloudkit.zone zone from the Zone dropdown list so that you query is hitting the correct set of data.

           

          I think I also found that indexes aren't created on all the fields of the CD_ record types. Particularly the Name field. IIRC I had to go into the Schema section of the Dashboard, select Indexes instead of the default selected heading Record Types and add a new Index for the field CD_Name. How do you add an index on that page? Well if your existing list of indexes is very long and scrolls off the screen, you may waste time trying to find the "Add Index" button, because it's unhelpfully located at the bottom of the list of indexes.

           

          Hope that helps.