Post

Replies

Boosts

Views

Activity

Core Data + CloudKit works for development but not production
I enabled Core Data + CloudKit for my MacOS and iOS app to allow sync between the two. I was able to test the sync during development and it's been syncing to My development database container just fine and I can fetch the changes from both my apps. However, once I distributed my app to test flight/app store, the Production database is not getting any activity at all. I did made sure I deploy my database schema to production per other troubleshooting post online. Am I missing any additional setup required for production? Below is my Persistence struct for reference (edited the "App Name", using the the name of my app in actual file): static let shared = PersistenceController() let container: NSPersistentCloudKitContainer init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: "App Name") // Only initialize the schema when building the app with the // Debug build configuration. #if DEBUG do { // Use the container to initialize the development schema. try container.initializeCloudKitSchema(options: []) } catch { // Handle any errors. } #endif // Enable automatic syncing with CloudKit let description = container.persistentStoreDescriptions.first description?.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) description?.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) if inMemory { container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null") } // Load the persistent store with a completion handler that handles errors and initializes the container container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { print("Unresolved error with PersistenceStores \(error), \(error.userInfo)") } }) // Allow changes made in the view context to automatically propagate to other contexts container.viewContext.automaticallyMergesChangesFromParent = true }
2
0
861
Mar ’23