Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler:

Since Swift5.1 is released with modular stable(it mean I can run my project with any new swift versions without any error). Why I got the error after upgraded from Xcode 11.1 to Xcode 11.2 ?
Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler:....
Please correct me if I misunderstand about modular stable?

2 Likes

You need to enable Build Libraries for Distribution for your project.

-enable-library-evolution compiler flag as I remember.

Thanks for your reply. Not sure I need enable this on my main project or need updated my libs too(Since I updated those for running in Swift 5.1, Xcode 11.1)? Because I tried to updated Build Libraries for Distribution to Yes but still got the same error. For example one of those errors:

1 Like

That needs to be the mode used to build the library. Module stability only applies to libraries built that way.

5 Likes

Thanks for make it clear to me. Maybe I will need some pull requests to those libs :smile:

Are there some known issues/limitations with this build setting in Xcode 11.2?

I've tried turning it on for a big library (which includes some Objective C and C++ code in it as well), but it seems to completely break the LLVM compiler when turned on. I basically get segmentation faults, which is not good.

This may gain more traction if you post it on a new thread.

2 Likes