-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
warning run: Publishing changes from within view updates is not allowed, this will cause undefined behavior. #7
Comments
Is there any chance the warning is on the wrong line and you are publishing changes within view updates on your side? Could you give a small isolated expample off when this shows? Maybe I'll have time to look into this soon. |
Sorry for a very late reply. The warning appears pretty much all the time, even in the simplest case. For example, here:
It seems it is Xcode 14 bug as this issue was not presented in Xcode 13.4.1, but I did not test the beta 3 or any RC version of Xcode 14.1 yet... |
In that example there isn't much point to pass the text into a state object as every time the view inits you create a new one. |
That's just simple example when the warning appears. It did not appear before on the old Xcode version. It appears also in for example, this example:
And this one:
Which are little bit modified versions of the first one. If I set Minimum Deployments to iOS 14 and delete the library, then it does not show any warning. If you think that it is expected behaviour for these cases, please, could you give any simple example that will not have this warning. |
Hmm, you're right. I haven't looked into it but I assume it has to do with the projected value. In the init I call publisher.send() twice. The first issue I see is possible is that the queue switch there to wait for the change comes back during the view runloop. The second possible issue could be calling the publisher.send() synchronously in the init. Not sure. I'll look into it if I have time. |
It seems putting parentObject?.objectWillChange.send() inside DispatchQueue.main.async in setParent<Parent: ObservableObject> function fixes the problem with warning.
|
Xcode Version 14.0.1 (14A400) started to show this warning
The text was updated successfully, but these errors were encountered: