swift 2.3 to swift 3.0

2019-08-03 08:23发布

I have a project that was started using swift 2 in xcode 7. I am now using swift 2.3 in xcode 8. When I try to migrate to pro 3 I get several errors no project. Both from the libraries and from my code. First I update my pods and then do an automatic conversion of the project. My doubts are: In case some library can give rise to error I can unlock it and convert? Do I have to prepare something before starting the conversation? In the articles I read about it, I did not say anything else about it. In case you continue using swift 2.3 will you have any future problems?

The application is very large, what would be the best option?

标签: ios swift swift3
1条回答
Animai°情兽
2楼-- · 2019-08-03 09:24

Honestly? Any project built with Swift since 2014 should be done with an understanding of code will break with every new version through Swift 3.X. (I'm not at all being critical, just practical.) This year, Swift 4.X is working hard to not break Swift 3.X code.

So with that starting point, here's my thoughts:

  • 1 Take a backup of a working Swift 2.X app and archive it. Backup that backup.
  • 2 Accept the price that should have been known when using any version before 3.X - the conversion will be painful and time-consuming.
  • 3 Wherever possible, do not use third party add ins. They can add to the complexity of migrating to the latest version.
  • 4 Do consider waiting for Swift 4. I'm not recommending this at all, but saying consider the big picture. But always remember eventually you will have to port things. (The good news is Swift 3 appears stable enough to say future upgrade will not be (at least) as painful.
  • 5 Consider migrating everything at once. (If you have that golden backup duplicated in several places, that makes it easier.) Yes, there are ways to migrate individual project, files, etc. from 2.X to 3.X - and 4.X (along with what is likely Xcode 9) makes things easier going forward. But only if you are starting from 3.X.
  • 6 Regards to Swift 2.3... the latest version of Xcode will not compile/build Swift 2.3. Take that as a sign - someday it will no longer be accepted in the App Store. That day may be 2-3 years away (or not), but It's almost 2 years since the promises of ABI and version compatibility were meant for Swift 3.0. BTW, only the latter happened.

Welcome to the world of a very fast evolving language!

EDIT: Regards to point #3 (avoid third party add ins where possible), I found two links expressing the issues that can come up:

Analyzing Third Party Libraries

Avoiding Third Party UI Libraries

查看更多
登录 后发表回答