UIHostingController presented modally cannot be dismissed programmatically

Originator:adilson05uk
Number:rdar://FB9116652 Date Originated:24/05/2021
Status:Open Resolved:Xcode 13.0
Product:SwiftUI Product Version:14.6
Classification: Reproducible:Yes
 
*Please describe the issue:*

A UIHostingController object presented modally from a UIViewController cannot be dismissed programmatically by means of `presentationMode.wrappedValue.dismiss()`. The UIHostingController is dismissed however if it is pushed rather than presented. See https://github.com/adil-hussain-84/SwiftUIExperiments/tree/master/App2 for a small, minimal UIKit application which demonstrates the problem.

*Please list the steps you took to reproduce the issue:*

1. Initialise a UIHostingController object (which has a SwiftUI root view).
2. Present (modally) the UIHostingController object from a UIViewController.
3. Tap a Button in the SwiftUI view contained within the UIHostingController which calls `presentationMode.wrappedValue.dismiss()`.

*What did you expect to happen?*

The UIHostingController object is dismissed.

*What actually happened?*

The UIHostingController object is not dismissed.

Comments

Resolved in Xcode 13.0

This issue is resolved in Xcode 13.0 beta 5. I tested it against an iPhone 15.0 simulator.

By adilson05uk at Aug. 27, 2021, 11:11 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!