user6410342
user6410342

Reputation:

Migrating a module written in Swift 3.0 to Swift 2.3?

The company I currently work for supports legacy products written in Swift 2.3 (I don't agree with it). At the moment they currently want to continue rolling out features supporting the legacy version and thus, I'm currently in a bind concerning a pod written in Swift 3.0.

I attempted to convert the syntax back to Swift 2.3 by installing Xcode 7.3.1 with the intention of hopefully migrating that code. Unfortunately, since it's a module written in Swift 3.0 my efforts were futile.

I'm out of suggestions though I'm not opposed to writing the code in the module in Swift 2.3 however I know I'll be looking at a tedious process for the long run. What steps should I take to migrate a module written in the most updated version of Swift back to version 2.3?

Upvotes: 0

Views: 137

Answers (1)

Papershine
Papershine

Reputation: 5223

Firstly, you can use Xcode 8 to do this. Select each of your schemes and then set 'use legacy swift version' in build settings to yes. Compile and then run. Swift will start presenting lots of errors. For example, this code (in swift 3):

SKAction.rotate(byAngle: CGFloat(M_PI_2), duration: 10)

is

SKAction.rotateByAngle: CGFloat(M_PI_2), duration: 10)

in swift 2. You have to manually fix all the errors that swift says, so you need a clear understanding of the old swift syntax.

Upvotes: 2

Related Questions