Extra trailing closure passed in call

"Extra trailing closure passed in call"

{ of ScrollView is underlined

Xcode Version 14.2 (14C18)

Cleaned build folder and restarted xcode.

This is a new view inside existing project.

Any Ideas?


struct ContentView: View {
    var body: some View {
        ScrollView {
            VStack {
                Text("Hello World")
            }
        }
    }
}

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

Since you say this is a new view inside an existing project, if you comment out that new code, do you still get the error? I'm just trying to figure out whether it's in this code or some other code, as I've just added your simple code into my project and there are no issues.

Yes, If ScrollView is removed the error goes away.

If ScrollView is added to any other view the same error occurs.

It sounds a little bit like there might be a struct called ScrollView defined elsewhere in your project. I get this exact error message with the following code in a new project:

struct ScrollView: View {
    var body: some View {
        Text("")
    }
}

struct ContentView: View {
    var body: some View {
        ScrollView {
            VStack {
                Text("Hello World")
            }
        }
    }
}

You can quickly verify this by changing ScrollView to SwiftUI.ScrollView in the line that's giving you the error. If the error message goes away, there must be another ScrollView somewhere in your project.

Extra trailing closure passed in call
 
 
Q