UIHostingController presented modally cannot be dismissed programmatically

Originator:adilson05uk
Number:rdar://FB9116652 Date Originated:24/05/2021
Status:Open Resolved:
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


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!