Ghostboard pixel

Should You Migrate Objective-C Code To Swift?

Should You Migrate Objective-C Code To Swift?

The future belongs to Swift, but does this mean that you should migrate Objective-C code to Swift?

Option #1:  Don’t Migrate Your Code And Stick To Objective-C

On the first sight this is the easiest way. Since you have already a running project written in Objective-C, it will not be a problem to continue it that way. However, there are some disadvantages about this approach:

In the future there will be less good Objective-C developers because there are a lot of iOS developers who are changing their focus to Swift. So if you are dependent on other developers, it could become difficult to maintain pure Objective-C projects in the future.

But even if you are maintaining the project on your own, this approach has its downsides, too. If you don’t get any practice in Swift, you are missing the most important new Apple development technology since the introduction of the iOS SDK. You have to learn Swift at some point, if you want to keep up-to-date.

Option #2: Migrate Objective-C Code To Swift

This way is the most radical approach. But converting a whole project form Objective-C to Swift means to write a complete new app. Although Objective-C and Swift have a very good interoperability, their programming paradigms are very different. So if you migrate Objective-C code to Swift, there is a high danger to use the wrong programming paradigms.

You also have to invest a lot of time and money. So if you are not planning to rewrite your App anyway, this approach is a little bit exaggerated.

Option #3: Write Just New Code In Swift

This approach is a very good compromise. Since the operability between Objective-C and Swift is very good, you can write new classes in Swift and let them interact with your existing Objective-C code.

This way you have the possibility to migrate your project step by step to Swift without investing a lot of time and money. Moreover it is also better for the learning process. Instead of rewriting a complete app, you can concentrate on a small part of the app.

Also the risks are much smaller. If you are taking this approach and you will see that you don’t like Swift at all – although it is very unlikely that this will ever happen – you can just switch back to Objective-C without loosing a lot of time and money.

[thrive_text_block color=”blue” headline=”Conclusion”]Although there could be situations where it is worth to migrate your Objective-C code to Swift, the best compromise is to write just new code in Swift and let it interact with existing Objective-C code.[/thrive_text_block]

References

Image: @ Karashaev / shutterstock.com
Should You Use Objective-C or Swift?