I've included stubbed code samples. I'm not sure how to get this presentation to work. My expectation is that when the sheet presentation closure is evaluated, aDependency should be non-nil. However, what is happening is that aDependency is being treated as nil, and TheNextView never gets put on screen.
How can I model this such that TheNextView is shown? What am I missing here?
struct ADependency {} struct AModel { func buildDependencyForNextExperience() -> ADependency? { return ADependency() } } struct ATestView_PresentationOccursButNextViewNotShown: View { @State private var aDependency: ADependency? @State private var isPresenting = false @State private var wantsPresent = false { didSet { aDependency = model.buildDependencyForNextExperience() isPresenting = true } } private let model = AModel() var body: some View { Text("Tap to present") .onTapGesture { wantsPresent = true } .sheet(isPresented: $isPresenting, content: { if let dependency = aDependency { // Never executed TheNextView(aDependency: dependency) } }) } } struct TheNextView: View { let aDependency: ADependency init(aDependency: ADependency) { self.aDependency = aDependency } var body: some View { Text("Next Screen") } }