SwiftUi strange behaviour (bugs?)

Hello.
I am trying to use SwiftUI in my pet project and get some strange behaviour:
  1. If I put more than ten subviews into VStack/HStack/ScrollView/List, I got error "Extra argument in call", but there is no extra argument (actually, I get this error if I just add 11 Text("Hello, world!"))

  2. If I put List into ScrollView, this list is not rendered (just empty space instead it), but there is no any error/warning/log messages (like for wrong constraints)

I have wrote simple project to illustrate this behaviour. Actually I have found workarounds, but this cases look like a SwiftUI bug. I misunderstand how I can check this issues are knowns or not and how I should create bug report (I understand that I should use Feedback Assistant, but what category?)

Thanks, Alex



Accepted Reply

  1. If I put more than ten subviews into VStack/HStack/ScrollView/List, I got error "Extra argument in call", but there is no extra argument (actually, I get this error if I just add 11 Text("Hello, world!"))

It is a know limitation of the current implementation of SwiftUI. The Swift language currently does not support variadic generic parameters. So, in the implementation @ViewBuilder, can only get 10 arguments.

I get this error if I just add 11 Text("Hello, world!")

That Text("Hello, world!") definitely is the extra argument. All the views declared in VStack/HStack/ScrollView/List... are passed to a hidden method, each view as an argument.


If I put List into ScrollView, this list is not rendered (just empty space instead it), but there is no any error/warning/log messages (like for wrong constraints)

This is another known issue.
You can find some articles searching with "swiftui list in scrollview".
List hides when adding in ScrollView SwiftUI
(Seems this is not as famous as the 10-view-limitation.)


You can send some feedback about these issues, whether they are known or not.

Replies

  1. If I put more than ten subviews into VStack/HStack/ScrollView/List, I got error "Extra argument in call", but there is no extra argument (actually, I get this error if I just add 11 Text("Hello, world!"))

It is a know limitation of the current implementation of SwiftUI. The Swift language currently does not support variadic generic parameters. So, in the implementation @ViewBuilder, can only get 10 arguments.

I get this error if I just add 11 Text("Hello, world!")

That Text("Hello, world!") definitely is the extra argument. All the views declared in VStack/HStack/ScrollView/List... are passed to a hidden method, each view as an argument.


If I put List into ScrollView, this list is not rendered (just empty space instead it), but there is no any error/warning/log messages (like for wrong constraints)

This is another known issue.
You can find some articles searching with "swiftui list in scrollview".
List hides when adding in ScrollView SwiftUI
(Seems this is not as famous as the 10-view-limitation.)


You can send some feedback about these issues, whether they are known or not.
The simplest solution to issue #1 is to place your views (10 or less) into Groups, e.g.:

Group {
Text("Hello, World! 1 ")
Text("Hello, World! 2 ")
Text("Hello, World! 3 ")
Text("Hello, World! 4 ")
Text("Hello, World! 5 ")
Text("Hello, World! 6 ")
Text("Hello, World! 7 ")
Text("Hello, World! 8 ")
Text("Hello, World! 9 ")
Text("Hello, World! 10 ")
}

Group {
Text("Hello World! 11 ")
...
}