Updated for Xcode 13.3
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")
}
}
SPONSORED Fernando's book will guide you in fixing bugs in three real, open-source, downloadable apps from the App Store. Learn applied programming fundamentals by refactoring real code from published apps. Hacking with Swift readers get a $10 discount!
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.