SwiftUI: TabView shows in Preview but now showing on simulated devices

Viewed 141

I am using TabView in my SwiftUI app. I used the side Preview as I was building it. The bottom tab shows on all device types in the Preview section but when I build it to either a real device or simulate device, the TabView doesn't show at all.

1 Answers

Previews are for each individual view. They don't represent the whole app.

You'll need to set it as the root view inside YourAppName_App.swift.

@main
struct YourAppNameApp: App {
    var body: some Scene {
        WindowGroup {
            YourTabBarView() /// replace with the name of your tab bar view
        }
    }
}
Related