Module compiled with Swift 5.1.3 cannot be imported by the Swift 5.2.4 compiler:

I need help with this error, I updated from Xcode version 11.3.1 to 11.6 today, now I am unable to build my project successfully.

Most likely, you need to clean and rebuild your project. If you have binary artifacts you'll need updated versions built with the new compiler.

In the future, answers for questions like this can quickly be found on StackOverflow, so I'd suggest starting there.

Besides what Jon said, I would also recommend watching this talk: Binary Frameworks in Swift.

@Jon_Shier Thanks for the quick reply, I did start on StackOverflow however the solution I got there did not work for me, YES to Build libraries for distribution. hence I am here

Yeah, that's not a great answer from SO. But the other answers you should've found would suggest what I am, which is rebuilding your project and all of your dependencies. If you're using Carthage, for example, you'll need to tell Carthage to rebuild your dependencies separately from Xcode.

@suyashsrijan I am not a Swift Developer, I develop mobile apps using Xcode in React Native. what I need is just a solution to this problem, not to know about binaries in Swift. I hope I am making sense.
thank you so much for the quick reply

I am not using Carthage, just React Native

What imported frameworks are you using? I think if you just re-build everything (the imported frameworks and your mobile app) with the same compiler then the error should go away. BUILD_LIBRARY_FOR_DISTRIBUTION is only for frameworks and not apps.

The module that its crying about its Lottie
import Lottie

Looks like Lottie isn't using the BUILD_LIBRARY_FOR_DISTRIBUTION flag at the moment:

I think the best solution right now is to simply rebuild Lottie using Xcode 11.6.

Maybe we talking about a different way of building, I do clean the project and its cleans successfully but when I built it fails, I am doing all this on Xcode under the product Tab.
Or am I suppose to delete folders that have this data for binary files and restart, or rm -rf pods .

Yes, if you do pod install or pod update then it should work.

1 Like

@suyashsrijan that is exactly what I have been doing, I even deleted node_modules and tried npm i and pod install and pod update. I will now delete the pods folder and try again

I think you also need to rebuild the library. You should be able to do that from Xcode. If that too doesn't work, just completely remove pods from your project and set it up again!

@suyashsrijan Okay, I will try the first option to remove the pods folder and try clean it. then if that did not work, I will do this one.

1 Like

@suyashsrijan I managed to make it work, I had to delete the DerivedData folder that contains the Project build. Thanks a lot