How do I create a swift package that supports multiple swift versions?
My code compiles fine with swift 4.0, 4.2 and 5.0. If I update swift-tools-version inside Package.swift then I can't use it on 4.0 or 4.2, but if I add 4.2 or 5.0 to swiftLanguageVersions
it doesn't recognize the version enums.
If swift-tools-version is set to 4.0, .v5
is not recognized inside swiftLanguageVersions
If swift-tools-version is updated to 5.0 then the package will not work on 4.0
What is the correct way of doing this? Or once you update to the latest version of swift the package stops supporting older versions?
You can either create separate Package@swift-#.swift files for each version or starting in Swift 4.2 you can use the .version("#")
enum.
See: https://forums.swift.org/t/swiftlanguageversions-best-practices-for-libraries/18443