How to enable library evolution support for swift package

I am not sure if the question is even valid, but here we go.

I am building a framework A using Xcode. Framework A depends on framework B, so it is added as a SPM dependency to the Xcode project. Framework A will be delivered as a binary framework, that is why I have the flag Build For Distribution = YES.

And it complains:
Module 'Framework B' was not compiled with library evolution support; using it means binary compatibility forFramework B' can not be guaranteed`

Since for the framework B the source code is available, I am wondering if the library evolution support can be activated for it, and how.

Thanks!

2 Likes

Before simply enabling library evolution support, you should ask whether you need to turn it on, and whether framework B supports it.

Make source-available frameworks do not define a stable ABI, and so do not support library evolution mode. For example, SwiftNIO does not.

In this case, you can "hide" the use of framework B by using @_implementationOnly import B to import the framework. This will limit where you can use framework B, but it will make it a private dependency and remove the need to use library evolution mode.

2 Likes

My use case is currently "special", since framework B, statically linked with framework A, is also being used by the app importing framework A (This is done like that because Xcode does not currently support linking dependencies dynamically unless explicitly specified in the package manifest file). But this is another issue, discussed in other threads, so I don't want to deviate. In this case I am assuming that I need library evolution for framework B too.

After some research it looks like it was possible before to enable library evolution using swift unsafe flags,

but it looks unsupported.

Thanks for the help!

1 Like