I have managed to reproduce unwanted _dismiss changed behavior in the strangest way possible.
If you add ANY StoreKit code then on swiping up (i.e. exiting the app) and returning it will produce a bunch of changes.
In my app, this was an extremely disruptive bug as it would cause my WebView to reset, losing all state.
Here's the code:
import SwiftUI
import StoreKit
struct ContentView: View {
@Environment(\.dismiss) private var dismiss
var body: some View {
let _ = Self._printChanges()
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
// Any StoreKit code causes `_dismiss changed.`. Comment the line below and it no longer happens
ProductView(id: "testing")
}
.padding()
// Adding a View Modifier like .storeProductTask or .currentEntitlementTask also produces the issue
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: