Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conversion to Swift 3 with Xcode 8

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

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.

Then, I used the Edit -> Convert -> To current Swift syntax choosing Swift 3 for 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..

Can you point me to the right direction?

Screenshot to show you the problems

screenshot errors

like image 518
Andrea Mario Lufino Avatar asked Sep 26 '16 08:09

Andrea Mario Lufino


People also ask

Which Xcode supports swift3?

Swift 3 is the primary development language supported within Xcode 8 so there are a couple notes to consider if you chose to continue using Swift 2.3.

How do I upgrade my version of Swift?

You can also update every single Swift Package in your project at once. To do this, open the Files menu, navigate to Packages and then click Update to Latest Package Versions. Afterwards, make sure to test your project to see if everything still works, especially in projects with a lot of package dependencies.

How do I update my Swift 3 to Swift 5?

You need to redownload Xcode 10.1 from this page, convert your code to Swift 4, then redownload Xcode 10.2 and convert to Swift 5. The only other option I can think of is changing your Swift Version in your apps bundle and then seeing if it lets you convert but I don't think it will. Show activity on this post.


2 Answers

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) :/ .

like image 60
0ndre_ Avatar answered Sep 30 '22 12:09

0ndre_


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.

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 ).

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 ...

like image 20
Nikola Lukic Avatar answered Sep 30 '22 13:09

Nikola Lukic