We are encountering the following issue in iOS 16 when using the .onReceive modifier with an ObservableObject:
.onReceive(form.manager.$allValid) { isValid in
self.isSaveDisabled = !isValid
}
The error message displayed is:
Publishing changes from within view updates is not allowed, this will cause undefined behavior.
As per our understanding, in iOS 16, it is required for the ObservableObject class to be annotated with @mainactor in order to avoid such issues.
Steps to Reproduce:
- Use the code snippet above where form.manager.$allValid is being observed.
- Observe the behavior when this code executes.
Expected Behavior: The code should function without throwing the error, and changes should be made to isSaveDisabled without any warnings or undefined behavior.
Actual Behavior: We are seeing the error message: "Publishing changes from within view updates is not allowed, this will cause undefined behavior."
Please refer to the attached screenshot for the position where this error is being triggered.

We are encountering the following issue in iOS 16 when using the .onReceive modifier with an ObservableObject:
The error message displayed is:
Publishing changes from within view updates is not allowed, this will cause undefined behavior.
As per our understanding, in iOS 16, it is required for the ObservableObject class to be annotated with @mainactor in order to avoid such issues.
Steps to Reproduce:
Expected Behavior: The code should function without throwing the error, and changes should be made to isSaveDisabled without any warnings or undefined behavior.
Actual Behavior: We are seeing the error message: "Publishing changes from within view updates is not allowed, this will cause undefined behavior."
Please refer to the attached screenshot for the position where this error is being triggered.