I have app which supports two destinations: iPhone and Apple Vision, both using their native SDKs (iOS, visionOS). When I need to wrap iOS-only code inside #if os(iOS) compiler directive and I try to build visionOS app, the code inside #if os(iOS) block is used as well.


The only way how I can tell compiler that this code is for iOS is by saying it is not for visionOS.

Why is that? Is visionOS some kind of sub-platform of iOS? I didn't find any documentation for it. I'm using Xcode 15.0 beta 5 and you can simulate it simply by creating new visionOS-only app.
Okay, it was probably just bug on
Xcode 15.0 beta 5, onXcode 15.0 beta 8directives work as expected.