3 Replies
      Latest reply on Jun 26, 2019 3:38 PM by .Nick
      SpaceMan Level 1 Level 1 (10 points)

        I have an older Core Data / iCloud app that I wish to convert toi Core Data / CloudKit.  I also want to do a major update to iOS 13.0


        My questions are about the persistent store that is in 'ubiquity'.


        In my app, the original path to the persistent store is

        Original iCloud store path: /var/mobile/Containers/Data/Application/Blah1/Documents/iCloudStore.sqlite


        However, I have to add the options for the persistent store coordinatoor as follows:

        iCloudOptions = [NSDictionary dictionaryWithObjectsAndKeys:

                       @"iCloudStore", NSPersistentStoreUbiquitousContentNameKey, nil];


        The path to the actual persistent store in upbiquity is now

        Ubiquity iCloud store path: /var/mobile/Containers/Data/Application/Blah1/Documents/CoreDataUbiquitySupport/mobile~Blah2/iCloudStore/Blah3/store/iCloudStore.sqlite


        NSPersistentStoreUbiquitousContentNameKey is deprecated.


        The question is, can I just grab the persistent store that is in the Original location, or do I have to grab the persistent store that is in the Ubiquity location?


        Also, if I need to get the Ubiquity store, can. I use NSPersistentStoreUbiquitousContentNameKey with a deployment target of 13.0?


        Also, how do I delete the old iCloud data (or can I) for the user when the app starts using CloudKit?

        • Re: Questions About Updating Older Core Data / iCloud App to Core Data / CloudKit
          SpaceMan Level 1 Level 1 (10 points)

          Once I have the path, I plan to do this.


          lazy var persistentContainer: NSPersistentCloudKitContainer = {

              let container = NSPersistentCloudKitContainer(name: “MyAppName”)


             // Create a store description for a CloudKit-backed local store

              let cloudStoreLocation = URL(fileURLWithPath: Original or Ubiquity Path)

              let cloudStoreDescription =

                  NSPersistentStoreDescription(url: cloudStoreLocation)

              cloudStoreDescription.configuration = "Cloud"


              // Set the container options on the cloud store

              cloudStoreDescription.cloudKitContainerOptions =


                      containerIdentifier: "com.my.container")


              // Update the container's list of store descriptions

              container.persistentStoreDescriptions = [




              // Load store

              container.loadPersistentStores { storeDescription, error in

                  guard error == nil else {

                      fatalError("Could not load persistent stores. \(error!)")




              return container


          • Re: Questions About Updating Older Core Data / iCloud App to Core Data / CloudKit
            .Nick Apple Staff Apple Staff (40 points)

            Do not attempt to reuse the ubiquity store file. The only possible migration path is a heavy weight migration, that is manually moving objects from the ubiquity store to a new store file to use with CloudKit.


            You also need to be aware that in doing this, you are forever leaving behind clients on mixed versions of your app unless you plan to support bi-directional sync between the ubiquity and cloudkit stores yourself.