I was trying to use the new Random Unification features of Swift 4.2 and when trying to build it on Linux it was throwing an error telling that the new features were not available. After some debugging I discovered that by default Swift PM compiles with the lowest Swift version set by
swiftLanguageVersions or the
The underlying problem is stated in the Package Manager Swift Language Version API Update Evolution proposal:
Existing packages will not be impacted but they will not be able to use Swift language version 4.2 unless they update their manifest to tools version 4.2.
This implies that if we want to keep support for Swift 3.X and 4.X and allow the package to build with new Swift 4.2 features we need 3 (!?) package manifests:
Package.swift Package@swift-4.swift Package@swift-4.2.swift
This is only one of the great problems derived of having decided to use Swift for defining the Package manifest. And if we keep trying to use it we well end with tons of manifests to maintain. Swift is a programming language, not a markup language. IMHO it was an huge mistake to accept it for defining the package manifest and we should move towards another solution as soon as possible. Of course this is only the tip of the problems it creates, other examples are:
- Security (reading a simple manifest should not require using an execution sandbox (!?), which I am not sure how/if it is implemented on Linux and other platforms)
- Reading the manifest requires Swift PM libraries or executable.
- Mechanically editing the manifest is extremely complex and error prone (hopefully, not only Swift PM would want to read/write it!). Also, requiring SourceKit/SwiftSyntax to edit it feels to me like using a sledgehammer to crack nuts.
- Creating manifests forward and backward compatible is impossible if we want to add any feature in the
For all of these problems I think we should accept to move towards a new simple markup language-based manifest (in
.json, a new
.swiftpkg format or whatever).
I hope this helps reopening this debate as I think propagating the error of using
Package.swift is worse than redesigning the Package manifest once more.