Skip to content

SwiftUI warning - publishing changes within a view (Xcode b5) #7908

@sonisan

Description

@sonisan

How frequently does the bug occur?

All the time

Description

Using Xcode beta 5 triggers the following SwiftUI warnings:

[SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.

No warning was present in the previous beta 3.
My project uses Realm Sync with the @AutoOpen property wrapper. Besides the warning, the code is working as intended.

Stacktrace & log output

Warnings lead to the following block of code:

...
 @Published var asyncOpenState: AsyncOpenState = .connecting {
        willSet {
            objectWillChange.send() // <--- HERE
        }
    }

...
 private func asyncOpenForUser(_ user: User) {
        asyncOpenState = .connecting // <--- HERE

....

Can you reproduce the bug?

Yes, always

Reproduction Steps

Launch the complete code example from the SwiftUI quickstart on https://www.mongodb.com/docs/realm/sdk/swift/swiftui-tutorial/#complete-code

Version

10.28.5

What SDK flavour are you using?

MongoDB Realm (i.e. Sync, auth, functions)

Are you using encryption?

No, not using encryption

Platform OS and version(s)

macOS 12.5

Build environment

Xcode version: 14.0 beta 5

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions