Today, I'm working without cloudkit (all data are in a local Coredata), with one database on my Xcode project but with 2 containers on app.delegate :
-
one for a test environment : with storeURL ---> test.sqlite
-
one for a production environment : with storeURL --> production.sqlite
Everything is ok, the test data, is really separate from production data.
Now, I try to use cloudkit functions : I change NSPersistentContainer to NSPersistentCloudKitContainer
it's working and I could use data on 2 iPads.
BUT if I switch the test to the prod, now the data from test environnement is duplicate on the production environnement.
what mistake am I making? How could I use my two storeURL with cloudkit coredata?
Thanx for your help.
You need to associate the test & prod with its own container id. Add them via Xcode iCloud capabilities containers list.
let testContainerID = NSPersistentCloudKitContainerOptions(containerIdentifier:"your_bundle_id.test")
let prodContainerID = NSPersistentCloudKitContainerOptions(containerIdentifier:"your_bundle_id.prod")
Assign each container ID to the respective data store