-
Notifications
You must be signed in to change notification settings - Fork 161
Move platform requirements to availability annotations #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adding or raising the deployment platforms in the package manifest is a SemVer major breaking change as consumers must also add or raise their deployment platforms. This is a known limitation of SwiftPM. Unforunately this means that it's very difficult for non-leaf packages to adopt packages which declare their platforms in the manifest. Doing so puts the brakes on adoption and ecosystem growth. For 'core' packages like this one availability constraints should be expressed on declarations rather than in the manifest. This patch adds equivalent availability annotations to declarations across the package and removes platforms from the package manifest.
@phausler note that Swift 5.6 and Swift 5.7 still use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modulo the naming issues - this seems to be much more maintainable than just slapping availability on all the APIs. As soon as we can get some sort of resolution of the naming problems then I think this is mergable.
Package.swift
Outdated
// Availability Macro Utilities | ||
enum _OSAvailability: String { | ||
// This should match the package's deployment target | ||
case alwaysAvailable = "macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming nit: this should probably be more so named initialIntroduction
and not the "alwaysAvailable" since this is not something that has always been around.
case alwaysAvailable = "macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0" | ||
// Use 10000 for future availability to avoid compiler magic around | ||
// the 9999 version number but ensure it is greater than 9999 | ||
case future = "macOS 10000, iOS 10000, tvOS 10000, watchOS 10000" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be good to have a "pending" case for the 9999 versions
Package.swift
Outdated
let versionNumbers = ["1.0"] | ||
|
||
// Availability Macro Utilities | ||
enum _OSAvailability: String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming nit: this doesn't need an underscore since this is not public API (it is restricted to the package)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack, this was copy-pasta from Foundation. I've fixed this up now.
Package.swift
Outdated
case future = "macOS 10000, iOS 10000, tvOS 10000, watchOS 10000" | ||
} | ||
|
||
struct _Availability { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto here on the underscore.
Adding or raising the deployment platforms in the package manifest is a SemVer major breaking change as consumers must also add or raise their deployment platforms. This is a known limitation of SwiftPM.
Unforunately this means that it's very difficult for non-leaf packages to adopt packages which declare their platforms in the manifest. Doing so puts the brakes on adoption and ecosystem growth. For 'core' packages like this one availability constraints should be expressed on declarations rather than in the manifest.
This patch adds equivalent availability annotations to declarations across the package and removes platforms from the package manifest.