简体   繁体   English

Swift 5.0.1 编译的模块不能被 Swift 5.1 编译器导入

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

I have a VoiceSampler.framework that was built with Xcode 10.3我有一个使用 Xcode 10.3 构建的 VoiceSampler.framework

I am trying to use that framework in Xcode11 in a new project.我正在尝试在新项目中使用 Xcode11 中的该框架。 I have successfully added that framework, but when I write import VoiceSample in AppDelegate, I get the following error:我已经成功添加了该框架,但是当我在 AppDelegate 中编写import VoiceSample时,出现以下错误:

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 Swift 5.1 编译器无法导入使用 Swift 5.0.1 编译的模块:/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?我可以在 Xcode 11 中调整构建设置以使其工作吗? 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.此问题是由于您尝试嵌入使用不同编译器版本创建的预编译框架而引起的。

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 编译器版本必须与用于编译框架的版本相同。

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希望此限制将在未来的 Swift / 编译器版本中删除...有关更多信息,请参阅此处的“模块稳定性”一章: 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.正如其中一条评论中已经提到的,此问题的解决方案是升级或降级到适当的 Xcode 版本。 (Or, if possible, recompile the framework with the desired compiler version and then use the same compiler version for your project.) (或者,如果可能,使用所需的编译器版本重新编译框架,然后为您的项目使用相同的编译器版本。)

I was getting a similar problem for Sqlite.swift.对于 Sqlite.swift,我遇到了类似的问题。 Doing the following command worked for me:执行以下命令对我有用:

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

This was suggested here .这是在这里提出的。

Just need to set the Build Libraries for Distribution option to Yes in your framework's build settings.只需在框架的构建设置中将Build Libraries for Distribution选项设置为Yes

As I have already described here , the provider of VoiceSample should rebuild the framework with BUILD_LIBRARY_FOR_DISTRIBUTION = YES;正如我在这里已经描述的那样,VoiceSample 的提供者应该使用BUILD_LIBRARY_FOR_DISTRIBUTION = YES;重建框架。 . . In such case, you will be able to use VoiceSample with all Swift versions.在这种情况下,您将能够将 VoiceSample 与所有 Swift 版本一起使用。

The following commands resolved the compiler error以下命令解决了编译器错误

  1. carthage bootstrap --platform ios
  2. brew bundle
  3. pod repo update

在此处输入图像描述 If you using React Native to build your App, go to Xcode and click on File -> Workspace Settings... -> if you notice there is a small arrow that is the path to the DerivedData folder, click on that and the actual folder will appear with other iOS related folders, DELETE the DerivedData folder and rebuild your App.如果您使用 React Native 构建您的应用程序,从 go 到 Xcode 并单击File -> Workspace Settings... -> 如果您注意到有一个小箭头是 DerivedData 文件夹的路径,请单击该文件夹和实际文件夹将与其他 iOS 相关文件夹一起出现,删除DerivedData文件夹并重建您的应用程序。 everything will work smoothly now... thank me later现在一切都会顺利...稍后谢谢我

In my case problem will be in carthage.就我而言,问题将出在迦太基。 So, I, in Finder , deleted these files from your project's root folder:因此,我在Finder中从项目的根文件夹中删除了这些文件:

Cartfile.resolved, Carthage/ Cartfile.resolved,迦太基/

Then started carthage bootstrap --platform iOS (because I didn't need update carthage).然后开始carthage bootstrap --platform iOS (因为我不需要更新 carthage)。

But if you need update carthage so you don't need to remove files.但是,如果您需要更新 carthage,则无需删除文件。 Only write command carthage update --platform iOS fix this problem.只写命令carthage update --platform iOS修复这个问题。

In my case, with deleting the file Cartfile.resolved , and making a rebuild of my project enough to make it work again.就我而言,删除文件Cartfile.resolved并重建我的项目足以使其再次工作。 Just as Taras Chernysh suggested, I'm sorry I can't add it where it belongs but I still don't have enough reputation.正如 Taras Chernysh 建议的那样,很抱歉我无法将它添加到它所属的位置,但我仍然没有足够的声誉。

You need to set the Build Libraries for Distribution option to Yes in your framework's build settings, otherwise the swift compiler doesn't generate the necessary .swiftinterface files which are the key to future compilers being able to load your old library.您需要在框架的构建设置中将 Build Libraries for Distribution 选项设置为 Yes,否则 swift 编译器不会生成必要的.swiftinterface文件,这些文件是未来编译器能够加载旧库的关键。

This ends up in your project.pbxproj file as:这最终在您的project.pbxproj文件中为:

BUILD_LIBRARY_FOR_DISTRIBUTION = YES;

After setting this flag, a framework I compiled using Xcode 11.0 (swift 5.1) was able to be compiled with Xcode 11.2 (swift 5.1.2) and everything appears to be working correctly.设置此标志后,我使用 Xcode 11.0 (swift 5.1) 编译的框架能够使用 Xcode 11.2 (swift 5.1.2) 编译,并且一切似乎工作正常。

Here is a solution for this issue:这是此问题的解决方案:

  1. Update the Xcode to version 11.2.1将 Xcode 更新到版本 11.2.1
  2. Then copy the PayTM SDK 5.2.1 for iOS in you project from below link然后从下面的链接复制您项目中 iOS 的PayTM SDK 5.2.1

    https://drive.google.com/file/d/1zllbQU4hIyEp7BbRooMA2oQwt3G_VfEe/view https://drive.google.com/file/d/1zllbQU4hIyEp7BbRooMA2oQwt3G_VfEe/view

  3. Build the project构建项目

Note: check in the build phase in LINK BINARY WITH LIBRARIES section PaymentSDK.framework is there or not.注意:检查LINK BINARY WITH LIBRARIES 部分PaymentSDK.framework的构建阶段是否存在。 If not then add manually, otherwise it will give you error that module not found.如果没有,则手动添加,否则会给您找不到模块的错误。

For more help.. after solving this issue you can follow below link如需更多帮助..解决此问题后,您可以点击以下链接

http://blog.openwebsolutions.in/paytm-payment-integration-ios-swift-language/ http://blog.openwebsolutions.in/paytm-payment-integration-ios-swift-language/

Thanks.谢谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift 5.0.1编译的模块不能被Swift 5.1导入 - Module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1 安装 Xcode10.2.1 但仍然收到错误“Swift 5.1 编译器无法导入使用 Swift 5.0.1 编译的模块” - Install Xcode10.2.1 but still got the error 'Module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1 compiler' Swift 5.1编译的模块不能被Swift 5.1.2编译器导入 - Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler (Swift Playground 模板)Swift 5.1.3 编译器无法导入使用 Swift 5.1 编译的模块 - (Swift Playground Template) Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.3 compiler Xcode 11.2.1 错误 - 使用 Swift 5.1 编译的模块无法由 Swift 5.1.2 编译器导入 - Xcode 11.2.1 Error - Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler Swift 5.1.2 编译器 (couchbaselite) xcode 11.2 无法导入使用 Swift 5.1 编译的模块 - Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler (couchbaselite) xcode 11.2 使用 Swift 5.2.4 编译的模块不能被 Swift 5.3.1 编译器导入 - Module compiled with Swift 5.2.4 cannot be imported by the Swift 5.3.1 compiler 使用Swift 4.1.2编译的模块不能由Swift 4.2编译器导入 - Module compiled with Swift 4.1.2 cannot be imported by the Swift 4.2 compiler 使用Swift 5.0编译的模块不能由Swift 4.2.1编译器导入 - Module compiled with Swift 5.0 cannot be imported by the Swift 4.2.1 compiler Swift 5.0 编译器无法导入使用 Swift 4.2.1 编译的模块 - Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.0 compiler
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM