What effect does setting `platforms` have on Linux?

So I have a library that is not platform specific, it just requires Swift 5.5 or above.

Trying to run tests on macOS it throws an error like so:

error: 'withCheckedThrowingContinuation(function:_:)' is only available in macOS 10.15 or newer

However, my Package.swift does say:

// swift-tools-version: 5.9

I still need to add this in order to be able to run the tests on macOS:

platforms: [.macOS(.v11)],

But now looking at the Package.swift file this makes little sense from a linux perspective... It looks to me like the package is only available on macOS...

My question is, will linux just disregard the platforms line of a Package.swift?

I feel like it makes more sense that we define the minimum Swift version instead of Apple platforms?
Eg. something like platforms: [.swift(.v5_9)],
β†’ Is there some sort of proposal or discussion related to this that anyone knows of?

Linux does not have what Swift considers a "stable ABI." That is, it doesn't generally matter to Swift which version of Linux you have, only that you're on Linux (or Windows or FreeBSD or or or…)

On Apple platforms, Apple ships a fork of the Swift project built into the OS that applications link to. That means that new language features and functionality on Apple platforms are bound to Apple's OS release cycle. That means that some functionality, like withCheckedThrowingContinuation(), is only available on versions of macOS/iOS/etc. that include it, and is unavailable on older OSes.

In short, yes, Linux just ignores the platforms argument when you construct your package. :slight_smile:

6 Likes