使用 Xcode 8 转换为 Swift 3

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

Conversion to Swift 3 with Xcode 8

iosswiftxcodeswift3xcode8

提问by Andrea Mario Lufino

To use Xcode 8 with a Swift project we have to convert it to the new Swift 3 syntax.

要在 Swift 项目中使用 Xcode 8,我们必须将其转换为新的 Swift 3 语法。

I've a project with several cocoapods. First, I have installed all the new versions of these pods from the respective sources, so they are already converted to the Swift 3.

我有一个有几个 cocoapods 的项目。首先,我已经从各自的来源安装了这些 pod 的所有新版本,因此它们已经转换为 Swift 3。

Then, I used the Edit -> Convert -> To current Swift syntax choosing Swift 3for my main target (basically the real app). Everything seemed to be fine, but at the first build I received a lot of errors, even simple ones, fixable with the CMD+ALT+CTRL+F, but they increase at every build. I think that this conversion tool is not the best one, or something went wrong..

然后,我将Edit -> Convert -> To current Swift syntax choosing Swift 3用于我的主要目标(基本上是真正的应用程序)。一切似乎都很好,但是在第一次构建时,我收到了很多错误,即使是简单的错误,也可以使用 修复CMD+ALT+CTRL+F,但每次构建时它们都会增加。我认为这个转换工具不是最好的,或者出了点问题..

Can you point me to the right direction?

你能指出我正确的方向吗?

Screenshot to show you the problems

截图告诉你问题

screenshot errors

截图错误

采纳答案by 0ndre_

I know that it is sad, but there is no other solution than changing your code manually. It is the same with constrains which are also different and you have to change them all (if they are wrong) :/ .

我知道这很难过,但是除了手动更改代码之外没有其他解决方案。约束也是不同的,你必须全部改变它们(如果它们是错误的):/。

回答by Nikola Lukic

You can goto free services (for big files you must upgrade accont) , clear and easy :

您可以转到免费服务(对于大文件,您必须升级帐户),简单明了:

Online Convertor

在线转换器

You can make convertion by converting small block of code . Sometimes line by line .

您可以通过转换小代码块来进行转换。有时一行一行。

Other way is to make objectiveC bridge in your swift3 project.

另一种方法是在您的 swift3 项目中创建 ObjectiveC 桥接器。

Use (in combination with online convertor) Auto correct from xcode 8.Its very useful (must be careful with auto correct sometimes you will degrade code ).

使用(与在线转换器结合)从 xcode 8 自动更正。它非常有用(必须小心使用自动更正,有时你会降级代码)。

In the basics : Its not bad , you must fix all errors manually .Best way for learn swift 3 . 90% of errors are very easy to fix , just follow logs ...

基础知识:这还不错,您必须手动修复所有错误。学习 swift 3 的最佳方法。90% 的错误很容易修复,只需按照日志...