I have several projects that simply won't index - just goes on forever. Xcode 13 is a disaster, really. So much is broken.
Post
Replies
Boosts
Views
Activity
Same...XCode 13 is really a disaster. So. Many. Problems. Can't believe it was released.
Just came across this looking for info on @SectionedFetchRequest. Better late than never 😛.
See the accepted answer here: SwiftUI List not updating when core data property is updated in other view. This is a kludge of sorts, but a clever one that only adds two lines of code to fix the problem - no need for your workaround. SwiftUI updates the view when the view state changes, and you are changing the core data in view but with nothing to notify the view of the changes. The refreshID does that, causing the view to refresh when a swap is executed.
I consider this Apple's bug. The whole point of using @FetchRequest and @SectionedFetchRequest is make Core Data objects 'published' so they can be observed in view - but as you show quite clearly it doesn't work properly. IMHO any change to the underlying data in Core Data should force the view to update automatically.
One thing that occurred to me as I wrote this - maybe putting all the swap/reset, fetches etc in a VM than publishing from there would work (not sure, and I don't have time to try it), but that defeats the purpose of @FetchRequest and @SectionedFetchRequest.