How do I avoid a platform?

I am designing a multi platform app, but visionOS lacks a functionality.

I think I know how to support a platform only (#if os), but how to support all platforms except one?

#if os(iOS, macOS)
        .glassEffect(.regular.interactive())
#endif

is a no-no?

Answered by limtc in 848834022

I found a solution, easy!

        #if os(visionOS)
        #else
        .glassEffect(.regular.interactive())
        #endif
#if !os(visionOS)
    // some code used on all platforms except visionOS
#endif

But is it really needed? You can let the code compile for visionOS, just don't release your app for visionOS. In App Store Connect, for your iOS app, under Pricing and Availability, you can uncheck support for visionOS (Apple Vision Pro).

Accepted Answer

I found a solution, easy!

        #if os(visionOS)
        #else
        .glassEffect(.regular.interactive())
        #endif

Yeah but that's more awkward than the solution I gave. Typing a ! is easier than adding the #else.

How do I avoid a platform?
 
 
Q