How to target SwiftUI code to only the visionOS platform (Compiler Directive)

I am trying to do the following code:


    func withBackground() -> some View {
        #if os(visionOS)
        background {
            Material.thin
        }
        #else
        background {
            Color.offWhite.ignoresSafeArea()
        }
        #endif
    }

But Xcode 15 Beta 2 says the following:

Unknown operating system for build configuration os

How can I change the background ONLY for visionOS, while keeping it as is on the other platforms I support? Thanks!

Note: I have added Vision as a target, not just the "Designed for iPad" target

Upon further digging, it seems like I have to use xrOS as the target, but the xrOS specific changes don't take effect because the simulator is trying to run it in a Designed for iPad mode. How can we run this as a native visionOS app?

How to target SwiftUI code to only the visionOS platform (Compiler Directive)
 
 
Q