Hello. I am beta testing an app in TestFlight. I want to use a public database inside the cloudkit container, and I think that I have set things up that way (see below). But my testers can only see their own data and all records are being stored in the Private Database. I'm getting the results I want on my own iPhone (loading the app directly from xCode). But testers are not getting the same experience. It this because I am in TestFlight? Are there settings I have missed? Here is what I have done so far: In my DataController I have this:
init(inMemory: Bool = false) {
container = NSPersistentCloudKitContainer(name: "Main")
if inMemory { // this is set in static var preview
container.persistentStoreDescriptions.first?.url = URL(fileURLWithPath: "/dev/null")
}
guard let description = container.persistentStoreDescriptions.first else {
print("Can't set description")
fatalError("Error")
}
let publicStoreURL = description.url!.deletingLastPathComponent().appendingPathComponent("public.sqlite")
let containerIdentifier = description.cloudKitContainerOptions!.containerIdentifier
let publicDescription = NSPersistentStoreDescription(url: publicStoreURL)
publicDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
publicDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
let publicOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: containerIdentifier)
publicOptions.databaseScope = .public
publicDescription.cloudKitContainerOptions = publicOptions
container.persistentStoreDescriptions.append(publicDescription)
container.loadPersistentStores { _, error in
if let error = error {
fatalError("Error loading store: \(error.localizedDescription)")
}
}
In entitlements I added "Production" to com.apple.developer.icloud-container-environment (because I read somewhere that that is also needed). In the cloudkit console the container is set to Production as well. Have I goofed? Or have I neglected something? Getting desperate ;) Thanks.