Following the advice from the great John Sundell ( How Swift 5.3 enhances SwiftUI’s DSL | Swift by Sundell ) a colleague and I were trying to refactor some code to take advantage of new features in Swift 5.3 and take advantage of the view builder changes that would allow us to remove some of the AnyView casting we were doing.
The application is a mixed iOS and macOS app compiled with Xcode 12.0.1 on macOS (Catalina [my coleague] and Big Sur beta 9 [me]).
We noticed that this will not work unless we manually add the @ViewBuilder annotation before of the body property and we thought this would not be needed as it was treated as a special case and inherit the ViewBuilder was inferred by the compiler ( What's new in Swift - WWDC20 - Videos - Apple Developer ):
Hello everyone, sorry for bumping the topic (won't repeat it), but does anyone spot the stupid mistake I am likely to have made in the original post of this thread? Quite confused :/..
Hello @Lantua, sorry for not sharing more info earlier on.
Without sharing the entire project (small side project, but need to clean it up from company specific things) we are using Xcode 12.0.1 (compiling it on a Big Sur beta 9 Mac at the moment), I am happy to share more just need to understand a bit better what is needed.
I tried to drop your example in it and it does not compile in the existing project. It does compile in a brand new iOS only project, but it does not compile in a brand new macOS project (shared sample iOS and macOS projects): iCloud
Not sure why it would not work for macOS, there could be the stupid thing I was missing and I should have explained it is an iOS + macOS app.
It doesn't seem to compile on pure macOS project either . And I don't see any difference between View declarations in either platform. Looks like a bug, maybe you can file a bug report (maybe on https://feedbackassistant.apple.com/ since this is an Xcode bug?).