无法在 Swift 4.0.1 中导入使用 Swift 4.0 编译的模块 [英] Module compiled with Swift 4.0 cannot be imported in Swift 4.0.1

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

问题描述

然而,我使用相同的 Xcode 重新编译了框架,它仍然给我这个错误.

However I have recompiled the framework using the same Xcode and it still gives me this error.

  • 适用于两者的基本 SDK iOS 11.1
  • 适用于两者的 Swift 语言版本 Swift 4.0
  • 不使用 Pods/Carthage

希望有人知道

推荐答案

更新:

对于 Xcode 的发布版本:

当使用 Xcode 9.1、9.2、9.3、9.4、10 等使用早期 Xcode 工具构建的框架打开项目时,会发生此错误(以及涉及 Swift 4.1、4.2 等的类似错误).

This error (and similar errors involving Swift 4.1, 4.2, etc.) will occur when opening a project with Xcode 9.1, 9.2, 9.3, 9.4, 10, etc. that uses frameworks that were built with earlier Xcode tools.

要解决此问题,请使用 Carthage(carthage update --platform iOS)、Cocoapods(pod updatepod install)更新和重建您的框架代码>),或手动,使用新更新的 Xcode 工具.当您更新 Xcode 时,这些工具应该会自动更新,但如果没有,您可以按照以下原始答案中概述的步骤进行操作.

To fix the issue, update and rebuild your frameworks using Carthage ( carthage update --platform iOS), Cocoapods (pod update or pod install), or manually, with the new updated Xcode tools. The tools should be updated automatically when you update Xcode, but if not, you can follow the steps outlined below in the original answer.

您可能还需要清理您的项目 cmd + shift + k 和可能的构建文件夹 cmd + option + shift + k 以使 Xcode 不使用缓存框架建立.

You may also need to clean your project cmd + shift + k and possibly your build folder cmd + option + shift + k to get Xcode to not use cached framework builds.

在某些情况下,您可能还需要删除派生数据文件夹(通过转到 Xcode Preferences -> Locations -> Derived Data Folder 很容易找到(感谢 Stunner)

In some cases you may also need to delete your derived data folder (Easily found by going to Xcode Preferences -> Locations -> Derived Data Folder (Thanks Stunner)

对于 Xcode 的测试版:

请参阅下面的原始答案,然后按照上面的步骤操作.

See original answer below and then follow steps above.

原答案:

您可能仍然将 xcodebuild 工具设置为使用 Swift 4.0 构建的 Xcode 9.0,并且与 Xcode 9.1 beta 的 Swift 4.0.1 不兼容.

You probably still have your xcodebuild tools set to Xcode 9.0 which builds with Swift 4.0 and is incompatible with Xcode 9.1 beta's Swift 4.0.1.

使用以下命令在终端中签入:

Check in the terminal using the command:

xcodebuild -version

或者只是进入 Xcode 首选项 -> 位置并检查/将命令行工具更改为 Xcode 9.1.那么你应该设置.

Or just go into Xcode preferences -> Locations and check/change the command line tools to Xcode 9.1. You should be set then.

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

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