Static method 'buildExpression' requires that 'some TabContent<Tab<Never, YourTab, DefaultTabLabel>.TabValue>' conform to "View"

I genuinely don’t understand this mistake. Please explain it to me! Please.

Also line mistakes is at line number 9

Mistake: Static method 'buildExpression' requires that 'some TabContent<Tab<Never, YourTab, DefaultTabLabel>.TabValue>' conform to "View"

Code:

import SwiftUI

struct ContentView: View {
    @AppStorage("tab-view-customization")
    private var customization: TabViewCustomization
    @State var isHidden = false
    var body: some View {
        TabView {
            Tab("Home", systemImage: "house.fill") {
                YourTab()
            }
            .customizationID("com.@WOAUNBLOCKED.Home")
            Tab("Privacy", systemImage: "book") {
                StoryView()
            }
            .customizationID("com.@WOAUNBLOCKED.Privacy")
            Tab("About", systemImage: "person.circle.fill") {
                HomeView()
            }
            .customizationID("com.@WOAUNBLOCKED.About")
            Tab("Calculator", systemImage: "function") {
                CalculatorView()
            }
            .customizationID("com.@WOAUNBLOCKED.Calculator")
            Tab("Login", systemImage: "person.crop.circle.fill") {
                passview()
            }
            .customizationID("com.@WOAUNBLOCKED.Login")
            Tab("Clock", systemImage: "clock.fill") {
                ClockCombinedView()
            }
            .customizationID("com.@WOAUNBLOCKED.Clock")
                Tab("Color", systemImage: "paintpallet.fill") {
                    ColorView()
                }
                .customizationID("com.@WOAUNBLOCKED.Color")
                Tab("Notes", systemImage: "text.pad.header") {
                    Notesview()
                }
                .customizationID("com.@WOAUNBLOCKED.Notes")
                Tab("Developer", systemImage: "hammer.fill") {
                    devview()
                }
                .customizationID("com.@WOAUNBLOCKED.Developer")
                Tab("Podcasts", systemImage: "apple.podcasts.pages.fill") {
                    InternetAgainView()
                }
                .customizationID("com.@WOAUNBLOCKED.Podcasts")
                Tab("tv", systemImage: "play.tv.fill") {
                    TVView()
                }
                .customizationID("com.@WOAUNBLOCKED.tv")
                Tab("Recording Studio", systemImage: "camera.fill") {
                    RecordingStudioView()
                }
                .customizationID("com.@WOAUNBLOCKED.Recording Studio")
                Tab("Browser", systemImage: "globe.fill") {
                    BrowserView()
                }
                .customizationID("com.@WOAUNBLOCKED.Browser")
            Tab("Maps", systemImage: "map.fill") {
                MapsView()
            }
            .customizationID("com.@WOAUNBLOCKED.Maps")
            Tab("Cards", systemImage: "lanyardcard.fill") {
                CoolView()
            }
            .customizationID("com.@WOAUNBLOCKED.Cards")
            Tab("Hacks", systemImage: "shippingbox.fill") {
                HacksView()
            }
            .customizationID("com.@WOAUNBLOCKED.Hacks")
            Tab("Memes", systemImage: "exclamationmark") {
                AboutView()
            }
            .customizationID("com.@WOAUNBLOCKED.Memes")
            Tab("Settings", systemImage: "gear.circle.fill") {
                FormView()
            }
            .customizationID("com.@WOAUNBLOCKED.Settings")
            Tab(role: .search) {
                
            }
        }
        .tabBarMinimizeBehavior(.onScrollDown)
        .tint(.accentColor)
        .tabViewStyle(.sidebarAdaptable)
        .ignoresSafeArea()
        .tabViewCustomization($customization)
        .statusBar(hidden: isHidden)
        .navigationTransition(.automatic)
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}


TabContentBuilder result builder has buildBlock overrides with up to 10 arguments. What this actually means is that you can't pass more than 10 Tabs into the initialization closure of TabView (which is marked with @TabContentBuilder).

If you include only tabs up to "Podcasts" tab, your code compiles. The diagnostic is misleading though, it switches to this wrong "method requires that ... conform to ..." one in the case of more than 12 arguments.

1 Like

So that mean that I can only pass 10 tab, or there’s a solution to override 10 arguments.

Also please post full fixed code after your explanation. Thanks.

Group conforms to TabContent, so you can wrap your tabs in a Group {} such that there are no more than ten items per group and no more than ten groups at the top level.