presentationMode.wrappedValue.dismiss() Bug iOS 16 | SwiftUI 4

Until now, I used to hide certain views (e.g.: Sheets) with the presentationMode dismiss function. But in iOS 16, more specifically SwiftUI 4, Xcode tells me "Publishing changes from within view updates is not allowed, this will cause undefined behavior" when pressing a Button with the dismiss function. My Question is if this is generally not the right approach, if it is a Swift bug or did SwiftUI 4 change something, so it is the wrong approach now. And if it is not the first, a solution for the problem.

Thanks in advance

It's not clear at this stage, but discussions on the wider Internet suggest that this may be a bug in Xcode 14.

When used like this I have no issues:

struct SomeView: View {

    @Environment(\.dismiss) var dismiss

    // called via a Button or some UI action of SomeView when presented by a parent View
     private func save() {
          DispatchQueue.main.asyncAfter(deadline: .now() + 0.763) {
            dismiss()
        }
    }
}
presentationMode.wrappedValue.dismiss() Bug iOS 16 | SwiftUI 4
 
 
Q