是否可以在较旧的 Xcode 上编译最新的 Swift 版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44884571/
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:06:36  来源:igfitidea点击:

Is it possible to compile Latest Swift version on older Xcode?

swiftxcodeversionsnapshot

提问by Ahmad F

For instance, I would play around Swift 4.2, but I don't want to use Xcode 10 betaversion, I have Xcode 9.4.1.

例如,我会玩 Swift 4.2,但我不想使用 Xcode 10 beta版本,我有 Xcode 9.4.1。

I wonder if there is any way do it, is it possible?

我想知道是否有任何方法可以做到这一点,这可能吗?

回答by Ahmad F

I figured it out that Yesit is possible. You can achieve it by installing the latest Snapshot:

我发现是的,这是可能的。您可以通过安装最新的Snapshot来实现它:

Development Snapshots are prebuilt binaries that are automatically created from mainline development branches.

https://swift.org/download/#snapshots

开发快照是从主线开发分支自动创建的预构建二进制文件。

https://swift.org/download/#snapshots

Snapshot is a toolchain that you can install into Xcode which contains the latest compiler, leading to let you able to build your app on the latest tools.

Snapshot 是一个工具链,您可以将其安装到包含最新编译器的 Xcode 中,从而让您能够在最新工具上构建您的应用程序。



How to setup a snapshot into Xcode?

如何在 Xcode 中设置快照?

1- Download the latest snapshot (Xcode) from Swift website.

1- 从Swift 网站下载最新的快照 (Xcode) 。

2- Install the downloaded snapshot .pkgfile.

2- 安装下载的快照.pkg文件。

3- Run Xcode and then go to: Xcode -> Toolchains -> Manage toolchains.

3- 运行 Xcode,然后转到:Xcode -> Toolchains -> Manage toolchains。

4- After selecting "Components" - "Toolchains" options, you should see:

4- 选择“组件”-“工具链”选项后,您应该看到:

enter image description here

在此处输入图片说明

Select "Swift Developer Snapshot" and thats it! You might need to reset Xcode after doing the above steps.

选择“Swift Developer Snapshot”,就是这样!完成上述步骤后,您可能需要重置 Xcode。

Reminder: You should reselect "Xcode 8.3.3" option after done playing around Swift 4, as mentioned in Swift - Using Downloadssection:

提醒:您应该在玩完 Swift 4 后重新选择“Xcode 8.3.3”选项,如Swift - Using Downloads部分所述:

To submit to the App Store you must build your app using the version of Swift that comes included within Xcode.

要提交到 App Store,您必须使用 Xcode 中包含的 Swift 版本构建您的应用程序。

回答by Tim Vermeulen

If all you want to do is play around with Swift 4, you could also use the IBM Swift Sandboxwhich always has the most recent snapshot.

如果您只想玩转 Swift 4,您还可以使用IBM Swift Sandbox,它始终拥有最新的快照。

回答by a.masri

Although it is not directly from the Xcode, you could also use the Iswiftwhich should has the latest swift version (latest snapshot).

虽然它不是直接来自 Xcode,但您也可以使用应该具有最新 swift 版本(最新快照)的Iswift