Does anyone know why #swift 6 erases `some View` to `AnyView`?
At first I thought that ViewBuilder messes something up (e.g. due to the availability restrictions - even though those are the ones of #SwiftUI itself). But since the extra `_body` property has the same problem, it seems to me that this is #swift related.

Turns out that this is due to Xcode 16 using debug builds for previews as well, thus erasing `some` return types to their `@ _typeEraser` type (if any).

Thanks @joe for providing this insight and finding the build setting to turn this off: https://f.duriansoftware.com/@joe/113170928606701687

However, I haven't found a way to disable it in SPM. But for #SwiftUI, I simply “opened up" the `AnyView` wrapper using `Mirror`.

Joe Groff (@[email protected])

@[email protected] Yeah, previews and debug builds now share build products, so views in debug builds get the AnyView wrapping. You can set SWIFT_ENABLE_OPAQUE_TYPE_ERASURE=NO in the build settings to disable this separately (though this probably breaks previews, so you might want to set up a separate scheme if you use previews)

Durian Software
@ffried if Xcode thinks you’re building with previews enabled, it’ll implicitly wrap views in AnyView in order to facilitate dynamic reloading of the preview. That might be one reason
@joe Good point. Is there a way to disable this for Swift Packages, though?
@ffried at some point debug builds had the “make everything dynamically replaceable” enabled but release builds didn’t, not sure if there are other factors these days. I’ll ask around
@joe Very much appreciated, thanks!
@ffried Yeah, previews and debug builds now share build products, so views in debug builds get the AnyView wrapping. You can set SWIFT_ENABLE_OPAQUE_TYPE_ERASURE=NO in the build settings to disable this separately (though this probably breaks previews, so you might want to set up a separate scheme if you use previews)
@joe Awesome, thanks for looking into it!
Now I just need to figure out how to set that build setting for test builds only somehow.