Swift 5.1编译器无法导入使用Swift 5.0.1编译的模块 [英] Module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1 compiler

查看:601
本文介绍了Swift 5.1编译器无法导入使用Swift 5.0.1编译的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Xcode 10.3构建的VoiceSampler.framework

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

我正在尝试在新项目的Xcode11中使用该框架.我已经成功添加了该框架,但是当我在AppDelegate中编写import VoiceSample时,出现以下错误:

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:

使用Swift 5.0.1编译的模块无法由Swift 5.1编译器导入:/Users/apple/Projects/CaptureAppSwift/VoiceSampler.framework/Modules/VoiceSampler.swiftmodule/arm64.swiftmodule

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

是否存在我可以在Xcode 11中进行调整的构建设置以使其起作用? 还有其他解决方法吗?

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

推荐答案

此问题是由于您尝试嵌入使用其他编译器版本创建的预编译框架而引起的.

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

当前,仅当编译器版本匹配时,才能嵌入预编译的框架!用于编译项目的swift编译器版本必须与用于编译框架的版本相同.

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.

希望此限制将在以后的Swift/编译器版本中删除... 有关更多信息,请参见此处的模块稳定性"一章: https://swift.org /blog/abi-stability-and-more

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

正如其中一条评论中已经提到的那样,解决此问题的方法是升级或降级到适当的Xcode版本. (或者,如果可能,请使用所需的编译器版本重新编译框架,然后为您的项目使用相同的编译器版本.)

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.)

这篇关于Swift 5.1编译器无法导入使用Swift 5.0.1编译的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆