use NSPersistentCloudKitContainerOptions to configure the container identifier to sync with
class PersistenceApp1: ObservableObject {
static let shared = PersistenceApp1()
let container: NSPersistentCloudKitContainer
init(…) {
container = NSPersistentCloudKitContainer(name: “App1”)
let store = NSPersistentStoreDescription()
store.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.com.example.App1")
container = [store]
container.loadPersistentStores…
}
…
}
Also, make sure to add both container identifiers to your app's Signing & Capabilities > iCloud > Containers list
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: