Availability when using Library evolution/ resilience for third party libraries

So, we’ve ended up realizing we’d like to use the library evolution features for resilient api surfaces for our product (yes, needed for an enterprise solution where clients of libraries must be able to be replaced independently and don’t have source access. Both macOS and Linux. Aware of tool chain impedance matching on Linux required - that’s ok).

The question is how we can evolve our api with availability annotations?

Maybe I’m missing something, but it seems current annotations for availability is tied to platform or swift version only?

In practice we’d like to tie it to our package semver if possible.

Anyone else using this? How do you do?

Plan B right now would be to tie it to swift versions, but that will surely cause trouble down the line.

Maybe There are plans to support this that I missed? Seems to be needed for any third party wanting to use library evolution/ availability?



You haven't missed anything! The language currently only supports expressing availability in terms of OS version or Swift language version. I couldn't find an issue tracking this enhancement but I suspect there are a number of projects that would benefit from something like this.

One thing worth noting, though; you mentioned semver and I think it's important to clarify that traditionally semver allows source breaks on major version changes (which often result in binary compatibility breaks, too). Libraries must evolve stably along both axes in order for @available to be an effective tool.

1 Like

Thanks! Yeah, we don’t plan source breaks for majors - I should probably just have used the term “version” - arbitrary really, but some point where we can tie in availability. So what are others doing? No one using it or tying it to swift version, or?

I’ll file an issue for this when back online - also would need support for binary targets in SPM for Linux AFAICT - SAS some preparatory work there but would need both to make it fully usable.

For future googlers, here's the issue I filed:

Relevant exploratory document from years ago: swift/LibraryEvolutionManifesto.md at main · apple/swift · GitHub