Mike B
Mike B

Reputation: 73

SwiftUI Group{} Nested in VStack{} Throwing Errors

I am receiving two errors whenever I attempt to add a Group struct to the VStack struct. The first error is on line 5 VStack { and reads:

Static method 'buildBlock' requires that 'Group' conform to 'View'

The second error is on line 6 Group { and reads:

Missing arguments for parameters 'id', 'label' in call

Here is the complete code for the view file:

import SwiftUI

struct FailTest: View {
var body: some View {
    VStack {
        Group {
            Text("1")
            Text("2")
            Text("3")
            Text("4")
            Text("5")
            Text("6")
            Text("7")
            Text("8")
            Text("9")
            Text("10")
        }
        Text("11")
    }
}

Any idea why this is throwing these two errors? The code is based on multiple examples I have found online, as well as two books.

Upvotes: 1

Views: 1018

Answers (1)

Rob Napier
Rob Napier

Reputation: 299455

I cannot reproduce this problem using just the code you've provided (plus a trailing brace that this seems to be missing, suggesting this might not be precisely all the code in the fille). I suspect you other code in the project, possibly another definition of Group that is causing the problem. I recommend moving just this code into a Playground to explore.

I'm testing with the latest Xcode 11.5 GA build, in case that is a difference.

Upvotes: 3

Related Questions