Skip to main content

How to fix “Ambiguous reference to member 'buildBlock()'”

About 2 minSwiftSwiftUIArticle(s)bloghackingwithswift.comcrashcourseswiftswiftuixcodeappstore

How to fix “Ambiguous reference to member 'buildBlock()'” 관련

SwiftUI by Example

Back to Home

How to fix “Ambiguous reference to member 'buildBlock()'” | SwiftUI by Example

How to fix “Ambiguous reference to member 'buildBlock()'”

Updated for Xcode 15

SwiftUI allows up to 10 static children in each container, so if you try to add 11 or more you’ll get this error. To be clear, this means the following code is valid:

VStack {
    Text("SwiftUI")
    Text("SwiftUI")
    Text("SwiftUI")
    Text("SwiftUI")
    Text("SwiftUI")
    Text("SwiftUI")
    Text("SwiftUI")
    Text("SwiftUI")
    Text("SwiftUI")
    Text("SwiftUI")
}

But if you add a single more Text("SwiftUI") then the code will refuse to build.

To fix this problem, wrap your items in groups of 10 or fewer, like this:

VStack {
    Group {
        Text("SwiftUI")
        Text("SwiftUI")
        Text("SwiftUI")
        Text("SwiftUI")
        Text("SwiftUI")
        Text("SwiftUI")
    }

    Group {
        Text("SwiftUI")
        Text("SwiftUI")
        Text("SwiftUI")
        Text("SwiftUI")
        Text("SwiftUI")
    }
}
Similar solutions…
How to fix “Cannot assign to property: 'self' is immutable” | SwiftUI by Example

How to fix “Cannot assign to property: 'self' is immutable”
How to fix “Modifying state during view update, this will cause undefined behavior” | SwiftUI by Example

How to fix “Modifying state during view update, this will cause undefined behavior”
How to fix “Protocol 'View' can only be used as a generic constraint because it has Self or associated type requirements” | SwiftUI by Example

How to fix “Protocol 'View' can only be used as a generic constraint because it has Self or associated type requirements”
How to fix “Fatal error: No ObservableObject of type SomeType found” | SwiftUI by Example

How to fix “Fatal error: No ObservableObject of type SomeType found”
How to fix “Cannot convert value of type 'String' to expected argument type 'Binding'” | SwiftUI by Example

How to fix “Cannot convert value of type 'String' to expected argument type 'Binding'”

이찬희 (MarkiiimarK)
Never Stop Learning.