Skip to content

Better support for sharing in previews.#367

Merged
mbrandonw merged 46 commits intomainfrom
better-preview-sharing
Jan 14, 2026
Merged

Better support for sharing in previews.#367
mbrandonw merged 46 commits intomainfrom
better-preview-sharing

Conversation

@mbrandonw
Copy link
Member

We can emulate iCloud sharing in previews by making some updates to our mocks that power the sync engine.

@mbrandonw mbrandonw requested a review from stephencelis January 9, 2026 22:13

struct CountersListView: View {
@FetchAll var counters: [Counter]
@FetchAll(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)]>([])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep track of records deleted from the mock cloud database so that when fetching changes we can fetch deletions.

syncEngine: syncEngine
)
} else {
Form {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now emulate a cloud sharing view in previews!

Base automatically changed from fix-previews to main January 10, 2026 00:00
@mbrandonw
Copy link
Member Author

I scaled this PR back a bit since we went with a simpler model for emulating automatic sync in previews.

@mbrandonw mbrandonw merged commit 521a60e into main Jan 14, 2026
5 checks passed
@mbrandonw mbrandonw deleted the better-preview-sharing branch January 14, 2026 17:15
doozMen pushed a commit to doozMen/sqlite-data that referenced this pull request Jan 22, 2026
* 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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #410.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants