When is the right time to adopt Swift 3?

Oliver Jones
Itty Bitty Apps
Published in
4 min readJun 26, 2016

It has been two years since Apple introduced Swift.

In the first 12 months I was quite hesitant to recommend Swift as an implementation language. In fact I think my exact words were “hell no”. The tools were not stable and the language and libraries were quite immature during Swift’s freshman year.

However, in the last 12 months the language has been going from strength to strength. Apple open sourced Swift and opened up the evolution of the language to the broader community through Swift.org.

This has encouraged a wealth of community contributions to Swift through the Swift Evolution Process and the upcoming release of Swift 3 bears fruit from these efforts. Swift 3 brings with it the most significant changes the language has seen in its short lifetime.

Swift 3 and “The Great Renaming”

Probably the most significant change coming with Swift 3 is “The Great Renaming”.

During this last year the Swift Evolution Process has produced a number of proposals to clarify and standardise the naming scheme for the Swift Standard Library and how Swift imports Apple’s existing frameworks like Foundation, UIKit and Core Graphics. This has yielded the “Swift API Design Guidelines”.

This new naming standard means Swift 3 will be quite different from Swift 2 when working with these frameworks. With the move to Swift 3, nearly all existing Swift code will need to be migrated to the new naming standard and follow these guidelines.

Xcode 8 includes a migration tool to help with this transition. Tools are great but as is the case with most tools it is there to save you work, not remove all thought from the process. I’m of the opinion that all Swift application code will still need to be audited and reviewed by a human post migration. In addition, the migration tool can’t help you transition your existing application code to the new API guidelines. It only addresses how your code interacts with Apple’s frameworks and how that API has changed.

Swift 3 and ABI stability

One of the goals for Swift 3 was ABI stability. This didn’t happen. What this means is that in order to upgrade a project to Swift 3 all the Swift dependencies of that project also need to be updated to Swift 3. It is not possible to link a Swift 3 application with Swift 2 libraries.

ABI stability will most likely come to Swift 3 sometime in the next 12 months and at WWDC this year Chris Lattner stated that maintaining source compatibility will be a strong constraint when considering changes to the language going forward. So hopefully there will be no need for a “Great Renaming 2” next year.

When to Switch to Swift 3?

Teams should start planning for this now. Depending on the scale of an existing Swift codebase this migration could have a significant impact on a project. All of a project’s dependencies will also need to have adopted Swift 3 before the main application can adopt Swift 3. Libraries adopting Swift 3 and migrating to the new API Guidelines will likely change their own APIs as a result. This will mean a lot of uses of library code in an application will need to be changed. Something the Xcode 8 migration tool can’t help with.

To ease with the adoption of Swift 3, developers should become familiar with the new API Design Guidelines and begin adopting them in new code as of today.

If you have an existing Objective-C codebase, and you’ve not yet started adopting Swift, then you may want to hold off adopting Swift until version 3 ships later in the year. This will put you in a better position than adopting Swift 2.x at this late stage and then having to go through the migration process.

Adopting Swift 3 right now, while it is in preview/beta, will be a painful process as very little 3rd party library code is ready yet. Although this will likely change rapidly during the Xcode 8 and iOS 10 beta period.

Fortunately, for developers who want to take a slow and steady approach to Swift 3 adoption, Apple have introduced features into Xcode 8 to allow developers to continue to use Swift 2 beyond the release of iOS 10. Xcode 8 supports both Swift 2.3 and 3. You can not mix them together in a single application but you can continue to use 2.3 until it is convenient for your project and team to make the Switch to 3.

Is Swift the future of Cocoa development?

Short answer: Yes.

I’ve always thought that a tipping point for Swift adoption would be when Apple themselves started introducing frameworks that were Swift only. While Apple has yet to go that far, they are starting to introduce Swift only features to some of the foundation frameworks upon which everything is built. Changes that make working with these frameworks feel much more native to the Swift language. These additions, and Apple’s introduction of Swift Playgrounds for iOS as an educational aid speak to Apple’s commitment to push further toward a Swift only future.

It may be many years before Objective-C takes its final bows and exits the Cocoa development scene but on balance I think the advantages of Swift are quickly becoming apparent. If you’ve yet to jump on board the Swift bandwagon, the upcoming transition to Swift 3 might present the right opportunity to do so.

Based in Melbourne, Australia, Itty Bitty Apps builds great software on mobile and Mac for clients big and small. It also makes Reveal — Amazingly powerful runtime view debugging for iOS developers.

--

--

Oliver Jones
Itty Bitty Apps

Technical Director at Itty Bitty Apps. Working hard on my grey beard.