I'm unsure whether this belongs more to the PM category or versioning or something else so please point me in the right direction if this is the wrong place.
In the source code for the SwiftPM API there are statements like @available(_PackageDescription, introduced: 4.2, obsoleted: 5).
This appears to be different from what is usable from Xcode (10/11).
First: the _PackageDescription version identifier is set in some undocumented way (or I can't find the docs). I can only use swift/iOS/macOS, not custom identifiers.
Second: it appears that all symbols marked with @available(_PackageDescription, ...) are ignored by the compiler. At least that's the conclusion I draw from them being omitted from the public API in the PackageDescription dylib bundled with Xcode for v4 and v4.2.
I realize that the underscore in the _PackageDescription symbol indicates unofficial, undocumented, unfinished or secret for some other reason and I'm not gonna find any answers about Xcode things. I just want to ask in case there are answers to be found here so I would appreciate any information that helps me answer the following questions.
Is there a way to pass a version value to the compiler for a custom identifier so it's picked up in the @available statement?
Building a package still works. How can that be since the dylib in Xcode should throw errors when using the unavailable APIs?
Where is the binary for PackageDescription API v5? I can only find dylib files for v4 and v4.2 bundled with Xcode 11.
_PackageDescription is basically an internal compiler feature for easily versioning APIs in SwiftPM's PackageDescription library. Here is the post that explains this "feature". You don't see a binary for v5 because SwiftPM is able to use the same v4.2 binary for multiple tools version.
We could extend availability for supporting 3rd party libraries/packages but that should be discussed in the evolution category.
I'm not sure if you are asking how to do something like per library @available or asking specifics about how the to make sure you are using the right api in your Package.swift file. For the last part, Swift Tools Version goes at the top of your Package.swift to indicate which api you are using. (You can also use a version suffix on the files if you need to do different package files for different tools versions.)
@Aciid Thanks, that helps a lot, very informative! The hidden option solves my problem perfectly. I do find it strange though that the symbols simply disappear when the value is omitted. @thomasvl I was indeed asking about doing a per library @available as you put it. However since it's a compiler thing I see that it's unlikely and anyhow I don't really need it, I was merely curious. The versioned package manifest with a suffix is very interesting though, can you please tell me whether the following is the correct format? and how to build a specific version of the manifest? Package2.1.0.swift.