# Availability when using Library evolution/ resilience for third party libraries

**URL:** <https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341>\
**Category:** Using Swift\
**Tags:** abistability, availability\
**Created:** [July 31, 2022, 7:05am UTC](https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341 "2022-07-31T07:05:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hassila](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hassila/32/22647_2.png) [@hassila](https://forums.swift.org/u/hassila)\
**Post date:** [July 31, 2022, 7:05am UTC](https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341/1 "2022-07-31T07:05:15Z")

</div>

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?

Thanks,

Joakim

---

<div class="post-metadata">

**Author:** ![tshortli](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tshortli/32/15850_2.png) [@tshortli](https://forums.swift.org/u/tshortli)\
**Post date:** [July 31, 2022, 4:43pm UTC](https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341/2 "2022-07-31T16:43:06Z")

</div>

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](https://github.com/apple/swift/issues) 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.

---

<div class="post-metadata">

**Author:** ![hassila](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hassila/32/22647_2.png) [@hassila](https://forums.swift.org/u/hassila)\
**Post date:** [July 31, 2022, 6:52pm UTC](https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341/3 "2022-07-31T18:52:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hassila](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hassila/32/22647_2.png) [@hassila](https://forums.swift.org/u/hassila)\
**Post date:** [August 2, 2022, 9:28am UTC](https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341/4 "2022-08-02T09:28:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hassila](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hassila/32/22647_2.png) [@hassila](https://forums.swift.org/u/hassila)\
**Post date:** [August 9, 2022, 10:28am UTC](https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341/5 "2022-08-09T10:28:22Z")

</div>

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

> <https://github.com/apple/swift/issues/60458>
>
> \*\*Is your feature request related to a problem? Please describe.\*\*
> 
> We’ve ende…d 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?
> 
> Current annotations for availability is tied to platform or swift version only, but we'd want to tie it to our products version numbers instead.
> 
> Not sure the best way to express it, but if a typical swift macro would be:
> 
> \`@available(swift 5.1)\`
> 
> we'd want something like:
> 
> \`@available(ourProductName 2.0)\`
> 
> which we could use with e.g.
> 
> \`\`\`
> if #available (ourProductName 2.0) {
> return x
> } else {
> return y
> }
> \`\`\`
> 
> or e.g.
> \`@available(ourProductName , deprecated: 3, renamed: "newNameForThis")\`
> 
> \*\*Describe the solution you'd like\*\*
> Add support for third-party availability annotations to allow tying availability to our product releases instead of platform/swift versions.
> 
> \*\*Describe alternatives you've considered\*\*
> As a stop-gap we considered to tie it to Swift releases instead, which is not really a good workaround, but AFAWU it's fundamentally the only option we have (for it to work on both Linux and macOS) - and not very good conceptually.
> 
> \*\*Additional context\*\*
> Some background discussion here:
> https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [August 9, 2022, 4:36pm UTC](https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341/6 "2022-08-09T16:36:29Z")

</div>

Relevant exploratory document from years ago: [swift/LibraryEvolutionManifesto.md at main · apple/swift · GitHub](https://github.com/apple/swift/blob/main/docs/LibraryEvolutionManifesto.md#generalized-availability-model)
