Updated for Xcode 14.2
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 Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.