Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

glbrntt
Copy link

@glbrntt glbrntt commented Apr 8, 2025

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.

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.
@glbrntt glbrntt requested a review from phausler April 8, 2025 12:32
@glbrntt
Copy link
Author

glbrntt commented Apr 8, 2025

@phausler note that Swift 5.6 and Swift 5.7 still use platforms per [email protected] (enableExperimentalFeature and CompilerPluginSupport aren't available).

Copy link
Member

@phausler phausler left a 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"
Copy link
Member

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"
Copy link
Member

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 {
Copy link
Member

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)

Copy link
Author

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 {
Copy link
Member

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.

@glbrntt glbrntt requested a review from phausler April 16, 2025 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants