SupportedPlatform: linux not allowed?

Hello,

I am trying to define a Swift package using Swift 5.1 with one of the supported platform being linux.

It seems the type is unknown:

/Users/mremond/devel/swift/xmpp-update/XMPP/Package.swift:9:10: error: type 'SupportedPlatform' has no member 'linux'
        .linux,

Is that expected?

It seems it should be supported: Apple Developer Documentation

It seems that even without that linux value, SwiftPM on linux happily builds the package. It seems to ignore the platforms directive.

Is the platforms directive only intended to describe the dependency on Apple environments?

I believe the setting is only applicable for dependency resolution and deployment targets, it doesn't constrain the actual platforms the package can build for. I don't know why, but maybe @NeoNacho or @Aciid knows.

We couldn't reach a good solution for constraining the list of supported platforms but thought that ability to declare the minimum deployment target for Apple platforms is very useful on its own. Maybe in the future, we can have some API to actually restrict the list of supported platforms. Something like:

platforms: [.macOS(.v10_12), .linux, .only]

But I agree that it's a bit unfortunate/confusing that the API is called platforms but the only thing it configures is the minimum deployment target.

3 Likes

I've seen this cause a fair amount of confusion. Even just changing the name of the parameter would help, though that would of course still be a source-breaking change. But as part of any future set of API changes that update the tools version anyway, that might make sense.

I think it might also be better to have a way to explicitly call out platforms as unavailable (e.g. .unavailable(.macOS)) rather than make it a closed set (as .only would imply). That would avoid breaking future derivatives of new platforms, if they're based on existing ones that have a very similar API.