Skip to content

Box @Fetch* property wrappers in SwiftUI state when possible#486

Merged
stephencelis merged 6 commits into
mainfrom
swiftui-state
Jul 16, 2026
Merged

Box @Fetch* property wrappers in SwiftUI state when possible#486
stephencelis merged 6 commits into
mainfrom
swiftui-state

Conversation

@stephencelis

Copy link
Copy Markdown
Member

There are some bugs with how the @Fetch* family of property wrappers behave when view identity throughout the hierarchy changes, forcing the Fetch* child value to be reconstructed in a bad state. E.g. a parent view might have some @State driving a @Binding in a child view that also has a @FetchAll, and changing that @State can cause the @FetchAll to be inert and not render in the view.

A fix for this has been to hold onto @FetchAll in @State, but nested property wrappers are cumbersome to use, and in Xcode 27 it's not even possible due to @State becoming a macro.

So instead, let's bake the @State directly inside the @Fetch*, preserving the data as the view hierarchy evolves.

mbrandonw and others added 4 commits July 15, 2026 17:00
* Use LockIsolated in FetchBox

* fix

* fix

* Bump CI Xcode

* Fix?

* wip

* Revert library test CI runner change

* Smaller bump

* fix

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
@stephencelis
stephencelis merged commit a5856cb into main Jul 16, 2026
5 checks passed
@stephencelis
stephencelis deleted the swiftui-state branch July 16, 2026 02:41
@stephencelis
stephencelis restored the swiftui-state branch July 16, 2026 02:47
@stephencelis
stephencelis deleted the swiftui-state branch July 16, 2026 02:47
stephencelis added a commit that referenced this pull request Jul 17, 2026
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.

2 participants