如何在 Xcode 9.3 中切换到 Swift 4.0?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49667188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:36:19  来源:igfitidea点击:

How can I switch to Swift 4.0 in Xcode 9.3?

swiftxcodexcode9.3

提问by Vladyslav Zavalykhatko

It seems like I have only options to go to 3.3, or unspecified:

似乎我只能选择转到 3.3 或未指定:

enter image description here

在此处输入图片说明

Can I switch to 4.0 somehow?

我可以以某种方式切换到 4.0 吗?

采纳答案by bcr

Make sure you have updated xCode then under Build Settings, check the drop down options for Swift Compiler - Language.

确保您已更新 xCode,然后在 Build Settings 下,检查 Swift Compiler - Language 的下拉选项。

Furthermore, You can download Xcode 8.x and 9.x from Apple Download Portal, if you've premium developer account (apple id). You can install & work with both Xcode 9 and Xcode 8.x in single (mac) system. (Make sure you've Command Line Tools supporting both version of Xcode, to work with terminal)

此外,如果您拥有高级开发者帐户 (apple id),则可以从Apple 下载门户下载 Xcode 8.x 和 9.x。您可以在单个 (mac) 系统中安装和使用 Xcode 9 和 Xcode 8.x。(确保您的命令行工具支持两个版本的 Xcode,以使用终端)

回答by Artem

I was able to install swift 4.0 in XCode 10 with solution from here "Switching Swift Versions inside Xcode using Toolchains".

我能够使用“使用工具链在 Xcode 中切换 Swift 版本”的解决方案在 XCode 10 中安装 swift 4.0 。

But in the end this did not help. I stuck on error:

但最终这并没有帮助。我坚持错误:

< unknown>:0: error: unknown argument: '-enable-batch-mode'

<未知>:0:错误:未知参数:'-enable-batch-mode'

Even disablingnot helped. I got:

即使禁用也无济于事。我有:

< unknown>:0: error: unknown argument: '-disable-batch-mode'

<未知>:0:错误:未知参数:'-disable-batch-mode'



"Switching Swift Versions inside Xcode using Toolchains"shortly:

“使用工具链在 Xcode 内切换 Swift 版本”

  1. Download desired toolchain, and click to install.
  2. Select new toolchain in XCode Preferences.
    1. Select here:enter image description here
    2. Result here:enter image description here
  3. Use desired swift, beware caveats.
  1. 下载需要的工具链,点击安装。
  2. 在 XCode 首选项中选择新工具链。
    1. 在这里选择:在此处输入图片说明
    2. 结果在这里:在此处输入图片说明
  3. 使用所需的 swift,注意警告。


Another related: material.

另一个相关:材料