[SOLVED] Argument passed to call that takes no arguments – TabView

Issue

I created a new SwiftUI file and using xcode, I literally added the default tabview and it is throwing an error. I attempted to reproduce this error by creating a new Xcode project but it is working perfectly. If I delete the TabView code, it builds fine.

import SwiftUI

struct TabView: View {
    
    @State var tabSelection = 0
    var body: some View {
        Text("wowcool")
      
        TabView(selection: .constant(1)) {
            Text("Tab Content 1").tabItem { Text("Tab Label 1") }.tag(1)
            Text("Tab Content 2").tabItem { Text("Tab Label 2") }.tag(2)
        }
    }
}

struct TabView_Previews: PreviewProvider {
    static var previews: some View {
        TabView()
    }
}

Below is what I am getting:

enter image description here

Attempts to fix:

  1. Restarted Xcode
  2. Cleaned Project
  3. Deleted Derived data
  4. Restarted computer

Currently on Xcode 13.3 and macOS 12.3

Solution

You are overriding SwiftUI’s TabView. Rename your view to something else.

Answered By – Kou Ariga

Answer Checked By – Dawn Plyler (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.