如何在XCode 8游乐场使用Swift 2.3 ?

时间:2023-01-23 21:14:13

I have my playground project written in Swift 2.2 and I want take advantage of timeline visuals and try new debug features introduced in Xcode 8 beta. By default, Xcode 8 beta is using Swift 3 in Playgrounds and I cannot find a way to change that. Updating my code to Swift 3 is not an option unfortunately, because my code will be compiled on server with Swift 2.2 environment.

我的游乐场项目是用Swift 2.2编写的,我希望利用时间线可视化,并尝试Xcode 8 beta中引入的新的调试功能。在默认情况下,Xcode 8 beta在Playgrounds上使用Swift 3,我无法找到改变它的方法。不幸的是,将我的代码更新到Swift 3不是一个选项,因为我的代码将在使用Swift 2.2环境的服务器上编译。

3 个解决方案

#1


29  

Unfortunately, according to Apple it is impossible:

不幸的是,根据苹果公司的说法,这是不可能的:

For instance, Playgrounds in Xcode only work with Swift 3, and notably the Swift Playgrounds app for iPad also uses Swift 3. Xcode project templates all use Swift 3, and all documentation is presented in a format appropriate for Swift 3.

例如,Xcode中的Playgrounds只能使用Swift 3,尤其是iPad的Swift Playgrounds应用也使用Swift 3。Xcode项目模板都使用Swift 3,所有文档都以适合Swift 3的格式呈现。

More here.

更多的在这里。

#2


-2  

You can convert your Swift 2.2 to Swift 2.3 for use in Xcode-beta 8.

您可以将您的Swift 2.2转换为Swift 2.3,以便在Xcode-beta 8中使用。

Yes, Swift 3 is the default, but you get the following dialog when you do Edit > Convert > To Current Swift Syntax... in Xcode.

是的,Swift 3是默认的,但是当您编辑>时,您将得到以下对话框,将>转换为当前的Swift语法……在Xcode中。

This also created an entry in my project.pbxproj for SWIFT_VERSION = 2.3

这也在我的项目中创建了一个条目。SWIFT_VERSION = 2.3

如何在XCode 8游乐场使用Swift 2.3 ?

#3


-4  

I have a legacy playground (created using xcode 7) in a project that I've migrated to Swift 2.3 syntax on XCode 8 and my playground work even if it's still using Swift 2.3 syntax, so I guess there is a way.

我在一个项目中有一个遗留的游乐场(用xcode 7创建),在xcode 8和我的游乐场工作中,我已经迁移到Swift 2.3语法,即使它仍然使用Swift 2.3语法,我想还是有办法的。

#1


29  

Unfortunately, according to Apple it is impossible:

不幸的是,根据苹果公司的说法,这是不可能的:

For instance, Playgrounds in Xcode only work with Swift 3, and notably the Swift Playgrounds app for iPad also uses Swift 3. Xcode project templates all use Swift 3, and all documentation is presented in a format appropriate for Swift 3.

例如,Xcode中的Playgrounds只能使用Swift 3,尤其是iPad的Swift Playgrounds应用也使用Swift 3。Xcode项目模板都使用Swift 3,所有文档都以适合Swift 3的格式呈现。

More here.

更多的在这里。

#2


-2  

You can convert your Swift 2.2 to Swift 2.3 for use in Xcode-beta 8.

您可以将您的Swift 2.2转换为Swift 2.3,以便在Xcode-beta 8中使用。

Yes, Swift 3 is the default, but you get the following dialog when you do Edit > Convert > To Current Swift Syntax... in Xcode.

是的,Swift 3是默认的,但是当您编辑>时,您将得到以下对话框,将>转换为当前的Swift语法……在Xcode中。

This also created an entry in my project.pbxproj for SWIFT_VERSION = 2.3

这也在我的项目中创建了一个条目。SWIFT_VERSION = 2.3

如何在XCode 8游乐场使用Swift 2.3 ?

#3


-4  

I have a legacy playground (created using xcode 7) in a project that I've migrated to Swift 2.3 syntax on XCode 8 and my playground work even if it's still using Swift 2.3 syntax, so I guess there is a way.

我在一个项目中有一个遗留的游乐场(用xcode 7创建),在xcode 8和我的游乐场工作中,我已经迁移到Swift 2.3语法,即使它仍然使用Swift 2.3语法,我想还是有办法的。