mergesort / Boutique

✨ A magical persistence library (and so much more) for state-driven iOS and Mac apps ✨
https://build.ms/boutique/docs
MIT License
899 stars 43 forks source link

SwiftUI Error - Publishing changes from within view updates is not allowed, this will cause undefined behavior. #31

Closed devinhayward closed 1 year ago

devinhayward commented 1 year ago

I am trying to import data through a CSV file. Using .fileImporter (SwiftUI) and within the closure parsing the data and attempting to save to the Store.

The compiler then complains:

/SourcePackages/checkouts/Boutique/Sources/Boutique/Stored.swift:42 Publishing changes from within view updates is not allowed, this will cause undefined behavior.

Not sure if I am doing some undefined behaviour for the Boutique Package, or using it in the wrong way?

Thought I would point out this bug to your attention. Maybe something you are not aware of.

mergesort commented 1 year ago

Hey @devinhayward, thanks for the bug report! I looked into the issue when it started popping up during the beta period but unfortunately it appears that it's an issue when using Xcode 14/the latest SDK. I don’t have a fix for it, and I found a blog post that led to some conversations with the author of this blog post, but it seems the behavior is undefined or a bug in the latest SDK. The good news is that I've been using the for a month or two and haven't run into any problems, and I'm sad to say that the real fix likely lies in the Apple fixing the error or explaining how to properly handle this situation.

devinhayward commented 1 year ago

Understood. I will file feedback when I have time, and keep developing with the error in the meantime.

mergesort commented 1 year ago

Thanks @devinhayward! Wish I had a better solution, but that's how it is developing for Apple platforms sometimes. 😅