Better support for sharing in previews.#367
Conversation
|
|
||
| struct CountersListView: View { | ||
| @FetchAll var counters: [Counter] | ||
| @FetchAll( |
There was a problem hiding this comment.
Updated the CloudKitDemo to show an icon next to counters that are shared. We can now explore that functionality in previews thanks to the changes in this PR.
| package let databaseScope: CKDatabase.Scope | ||
| let _container = IsolatedWeakVar<MockCloudContainer>() | ||
| let dataManager = Dependency(\.dataManager) | ||
| let deletedRecords = LockIsolated<[(CKRecord.ID, CKRecord.RecordType)]>([]) |
There was a problem hiding this comment.
We keep track of records deleted from the mock cloud database so that when fetching changes we can fetch deletions.
| syncEngine: syncEngine | ||
| ) | ||
| } else { | ||
| Form { |
There was a problem hiding this comment.
We now emulate a cloud sharing view in previews!
|
I scaled this PR back a bit since we went with a simpler model for emulating automatic sync in previews. |
* wip * wip * wip * wip * wip * Better support for sharing in previews. * wip * wip * wip * clean up * wip * clean up * Trying out database pool for previews. * wip * wip * clean up * clean up * reformat * cancel timer when stopping sync engine * clean up * wip * wip * wip * clean up * wip * fixes * fix * wip * wip * Revert "fix" This reverts commit 090dd74. * Revert "wip" This reverts commit 43727d5. * Revert "wip" This reverts commit 6d5e42b. * modernize previews * wip * lock isolated * wip * wiup * clean up * Fix merge conflicts. * wip * format * wip * wip --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com>
| } else { | ||
| try DatabasePool(path: url.path(percentEncoded: false)) | ||
| } | ||
| let metadatabase = try DatabasePool(path: url.path(percentEncoded: false)) |
There was a problem hiding this comment.
@mbrandonw Hi Brandon, I ran into a crash when trying to execute tests on macOS 15. It seems that URL(string: "file:sqlitedata_icloud?mode=memory&cache=shared").path(percentEncoded: false) produces an empty string, resulting in DatabasePool(path: ""), which crashes trying to activate WAL mode. On macOS 26 (CI) it seems to return "sqlitedata_icloud" instead, hiding the issue. Seems like a change in Foundation.URL inner guts. I was wondering whether the DatabaseQueue branch was intentionally removed or if we should revert this change to continue supporting macOS 15?
There was a problem hiding this comment.
Ah, that makes sense. I removed this because it didn't seem to have an affect on anything, but I guess that's because I am on macOS 26. Want to PR to add it back?
We can emulate iCloud sharing in previews by making some updates to our mocks that power the sync engine.