Updated for Xcode 12.5
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 Building and maintaining in-app subscription infrastructure is hard. Luckily there's a better way. With RevenueCat, you can implement subscriptions for your app in hours, not months, so you can get back to building your app.
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.