The code seems to work and compile without adding @ViewBuilder to the body property when using the environment to check the vertical size class. Is this no longer necessary?
That’s correct — it seems redundant now. If you look at the View
protocol, you can notice that now the body properly has that modifier already applied:
@ViewBuilder var body: Self.Body { get }
I presume earlier versions of SwiftUI didn’t use that attribute, so you had to manually add yourself whenever needed.
Yes, I also found this in Chapter 7, but I don’t know since which SwiftUI version it is available.
And there is an article explaining this as well: https://www.avanderlee.com/swiftui/viewbuilder/