Reno, NV    +1 (800)0 621-0871

Go back

Development

Swift Catching Up With Big Brother

  |  October 7, 2016
Swift Catching Up With Big Brother

Photo: Pixabay

 

Recently, I was faced with an in-between situation: I started a development project which has to be delivered a couple of weeks shy with the release of Swift 3.0 and iOS 10. Of course, you cannot say no to your employer or client, or to hold off until the release of new language and libraries—that would be unwelcome. Like any other language update, you should expect some deprecation in syntax and functions, and probably a new set of APIs. You should also expect the app would relatively run albeit with some hiccups. However, that is not the case with the recent iOS update. Running Swift 2.2 on iOS 10 yields quite a trouble; either your app will crash and burn, or it will go straight to burning. A significant change in the language can be attributed to these issues.

As the saying goes, “With great power comes great responsibility.” Xcode comes with a great tool for converting Swift 2.x codes to Swift 3. Now, as a developer, your great responsibility is to make sure you have a repository to hold on to, and the diligence to run through your code once the conversion is done. Remember: although the conversion tool is great, it is not perfect. You will still spend some time going through the tedious process of updating the syntax and functions that were not converted.

They say time is a commodity, and spending it going through hundreds of lines of code can be taxing. Good thing Xcode also comes with Swift 2.3 migration tool. Yes, this 0.1 version update from 2.2 to 2.3 can work wonders! It will hasten the release of your app to be iOS 10 compliant. Think of it as an intermediary platform while you hammer on the update to Swift 3. Neat! Oh, but make sure to set the compiler version on Xcode to use legacy language (Build Settings -> Swift Compiler -> Version -> Use Legacy Swift Language Version = Yes).

Update such as this will continue as Swift plays catch up with its big and wiser brother—Objective-C. Until then, developers like us who have adapted to Swift will have to play tag as well. However, according to Apple, this will be the last version of Swift that will have code breaking; the future releases of the language will be backwards compatible. Think of it as a clean slate as it sheds to better practices and consistency with its future releases.