I really like the Swift type-systems. But I cannot fathom why I cannot do this:
var view: View
if #available(tvOS 15.0, *) {
view = ManageProfilesView.MainView(
viewModel: .init(),
action: { _ in }
)
} else {
view = ManageProfilesView.LegacyView(
viewModel: .init(),
action: { _ in }
)
}
let viewController = UIHostingController(rootView: view) // Type 'any View' cannot conform to 'View'
presenter.show(viewController, sender: presenter)
It's clear that both views are correct conformances of the View protocol, so the let view: View
should satifty the requirement of the UIHostingController<Content> : UIViewController where Content : View