apple/sample-cloudkit-privatedb-sync

Add basic error handling

Closed this issue · 1 comments

malhal commented

It might help those trying for the sample for the first time to discover errors in their CloudKit container configuration if the error "Couldn't get container configuration from the server for container containerID" was output to the console. I was able to see by adding the code below but it originates in line 65 of ViewModel.swift let changes = try await database.recordZoneChanges

            .onAppear {
                Task {
                    do {
                        try await vm.initialize() // replaces try? await vm.initialize()
                        try await vm.fetchLatestChanges()
                    }
                    catch {
                        print(error.localizedDescription)
                    }
                }
            }

I had the same problem as #6 and had to do some debugging to fix it, it was because I changed the bundle ID. Perhaps if the usual sample code disambiguator routine for an automatic unique bundle ID then it might prevent requiring to edit the bundle ID at all?

Fixed by #10