Module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1 compiler

最后都变了- 提交于 2020-01-10 04:47:07

问题


I have a VoiceSampler.framework that was built with Xcode 10.3

I am trying to use that framework in Xcode11 in a new project. I have successfully added that framework, but when I write import VoiceSample in AppDelegate, I get the following error:

Module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1 compiler: /Users/apple/Projects/CaptureAppSwift/VoiceSampler.framework/Modules/VoiceSampler.swiftmodule/arm64.swiftmodule

Is there a Build Setting I can tweak in Xcode 11 to make it work? Any other work around?


回答1:


This problem is caused by the fact that you attempt to embed a pre-compiled framework that was created with a different compiler version.

Currently, pre-compiled frameworks can only be embedded if the compiler versions match! The swift compiler version that is used to compile the project must be the same version that was used to compile the framework.

Hopefully, this restriction will be removed in future Swift / compiler versions... For more information refer to the chapter on "Module Stability" here: https://swift.org/blog/abi-stability-and-more

As already mentioned in one of the comments, the solution to this problem is to up- or downgrade to the appropriate Xcode version. (Or, if possible, recompile the framework with the desired compiler version and then use the same compiler version for your project.)




回答2:


I was getting a similar problem for Sqlite.swift. Doing the following command worked for me:

carthage update --platform iOS --no-use-binaries

This was suggested here.




回答3:


In my case problem will be in carthage. So, I, in Finder, deleted these files from your project's root folder:

Cartfile.resolved, Carthage/

Then started carthage bootstrap --platform iOS(because I didn't need update carthage).

But if you need update carthage so you don't need to remove files. Only write command carthage update --platform iOS fix this problem.



来源:https://stackoverflow.com/questions/58130048/module-compiled-with-swift-5-0-1-cannot-be-imported-by-the-swift-5-1-compiler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!