Can you show the code in action? I tried to reproduce and managed to get it working fine.
See if that works out for you:
struct TestingView: View {
@Environment(\.horizontalSizeClass) var sizeClass
var body: some View {
if self.sizeClass == .compact {
return AnyView(TabView {
Text("Hello World!")
.tabItem {
Text("Hello")
}
})
} else {
return AnyView(NavigationView {
List {
Text("Hi")
}
Text("Hello World!")
})
}
}
}