Why we need to add UIHostingController to view controller chain

Updated
Jun 9, 2022 5:27 PM
Created
Jun 9, 2022 5:26 PM
Tags
SwiftUI.framework
Attributes

When using UIHostingController, make sure to always add the view controller together with the view to your app.

Many SwiftUI features, such as toolbars, keyboard shortcuts, and views that use UIViewControllerRepresentable, require a connection to the view controller hierarchy in UIKit to integrate properly, so never separate a hosting controller's view from the hosting controller itself.