[swift-evolution] Idea: Support #if os(Darwin) as shorthand for os(iOS) || os(OSX) || os(watchOS) || os(tvOS)

plx plxswift at icloud.com
Sat Feb 20 09:53:29 CST 2016

Offhand it seems a decent solution would be to have some way for users to define e.g. an “os group” 

#define_os_group(uikit) iOS tvOS
#define_os_group(apple) iOS tvOS watchOS OSX

…(but with a better name).

It’s not clear offhand where such `#define*` statements would naturally reside.

As a bit of bike-shedding, perhaps `platform` instead of `os`, too.

> On Feb 19, 2016, at 1:19 PM, Kevin Ballard via swift-evolution <swift-evolution at swift.org> wrote:
> I'd like to see #if support os(Darwin) as shorthand for any Apple platform. This is a lot shorter to type, and it's also future-compatible if Apple ever releases another Darwin-based platform. If os(Darwin) evaluates to true, then `import Darwin` should always work, and presumably `import Foundation` as well.
> Without this, I think people are going to be tempted to write `if !os(Linux)` instead of writing out all 4 Apple platforms, and this is unfortunate because it makes the assumption that Linux is the only non-Apple platform, and that's simply not true.
> -Kevin Ballard
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list