`#if os(Darwin)`, a shorthand for checking for Darwin platforms

Apple seems ~1 year away from launching realityOS, an operating system for their overly expensive AR headsets - and years afterward, reasonably priced smart glasses. I did a lot of research into this topic while creating ARHeadsetKit, and Apple has been quietly adding features to Metal and ARKit that will someday enable AR headset experiences. Well, technically they already have because I made an AR headset experience.

The last time Apple released a new platform was watchOS in 2015. This was a year after Swift was released (2014). Since the language was new, I assume there was not much fuss about adding || os(watchOS) to a bunch of macros. But now, there might be because people want API stability. I tried adding || os(realityOS) to a Swift package to future-proof it and let it run on Apple's future wearable AR devices. It failed to compile because the platform was not recognized.

I haven't fully read through the discussion here, but I wanted to point out a reason os(Darwin) would be helpful. If someone's Swift packages switch to os(Darwin) now, they will be future-proofed when Apple launches their OS for AR headsets.

2 Likes