Thank you for your post. I am attempting to understand what you are tying to accomplish. Because you are using the UIHostingController I guess you are using UIKit and SwiftUI together?
It would be greatly appreciated if you could provide a focused sample to demo the issue, without code is really hard for me.
In my opinion I believe this error message suggests that you are attempting to directly add a subview to the view hierarchy of a view controller, which is not suggested and can result in issues with the view hierarchy. A view controller is designed to manage its own view hierarchy, and directly tampering with it can lead to unexpected behavior.
If you wish to overlay or add views around the SwiftUI content managed by a view controller, you should do so by adding your views to a common superview that contains the view controller’s view.
If your objective is to integrate UIKit views into SwiftUI, consider using to encapsulate a UIKit view and incorporate it within your SwiftUI view hierarchy.
Select the approach that best aligns with your architectural requirements, considering whether you are primarily working in UIKit or SwiftUI. However, providing some code will assist everyone in comprehending your intended functionality.
Albert Pascual
Worldwide Developer Relations.