2编译器无法导入使用Swift

2编译器无法导入使用Swift

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

问题描述

短篇小说:Xcode 10设置为Swift 4,但它使用的是Swift 4.2.

Short story: Xcode 10 is set to Swift 4, but it is using Swift 4.2.

长话短说:我们的项目还没有为Swift 4.2做好准备,因为我们的依赖框架还不是Swift 4.2.但是,我至少要使用Xcode 10.

Long story: Our project is not ready for Swift 4.2, since our dependent frameworks are not Swift 4.2, yet. But, I would like to, at least, use Xcode 10.

  • 我已经安装了Xcode 9.4.1和Xcode 10.
  • 我已将命令行工具设置为使用Xcode 9.4.1:
  • 在Xcode 10中,我将项目设置Swift语言版本设置为雨燕4.
  • In Xcode 10, I have the project setting, Swift Language Version, set toSwift 4.
  • 我已经在命令行上验证了Shell的Swift版本使用是4.1.2:
  • I have verified on the command line the Swift version the shell isusing is 4.1.2:

  • 我已经进行了迦太基更新.
  • 我已经退出Xcode 10并重新启动.
  • 我已经深度清理并删除了派生数据".
  • 我建造了并且出现了这个错误:
    • I've run carthage update.
    • I've quit Xcode 10 and relaunched.
    • I have deep cleaned and deleted Derived Data.
    • I build and I get this error:
    • 对我来说,这表明我正确设置了预期的Swift版本(4.1.2),而Xcode仍在尝试使用错误的Swift版本(4.2).

      To me, this indicates that I have my intended Swift version (4.1.2) set correctly and Xcode is still trying to use the wrong version of Swift (4.2).

      有人对如何解决此问题有建议吗?我想念什么吗? Xcode错误?

      Does anyone have suggestions on how to resolve this? Am I missing something? Xcode bug?

      推荐答案

      我不是很肯定,但是我猜这是原因:

      I'm not positive, but my guess is that this is the reason:

      您必须使用Xcode 10重新编译Swift 4依赖项,因为Swift 不是ABI稳定的 ,即使用不同版本的编译器编译的二进制文件不兼容.甚至使用不同版本的Xcode编译的Swift 4.0二进制文件也可能不兼容.

      You have to recompile your Swift 4 dependencies using Xcode 10, because Swift is not ABI-stable, i.e. binaries compiled with different compiler versions are not compatible. And even Swift 4.0 binaries compiled with different versions of Xcode may not be compatible.

      我对Carthage的经验不多,但是我的猜测是您应该将Xcode 10用作命令行工具,但是您必须设置一个不同的Swift语言版本以供Xcode 10使用.可以在项目中指定(在这种情况下为RealmSwift),也可以使用环境变量,但是恐怕您需要其他人来回答更多详细信息.

      I don't have much experience with Carthage, but my guess is that you should use Xcode 10 as a command-line tool, but you have to set a different Swift language version to be used by Xcode 10. It should probably be specified in the project (in this case RealmSwift), or using environment variables, but you'll need someone else to answer with more details, I'm afraid.

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

08-14 07:34