Main image of article Swift 5, ABI Stability May Prove Last Corner for Language to Turn
Swift 5, which is expected to land in the first half of this year, is bringing ABI stability with it. Now we’re getting a better idea of what that means for the language, as well as the broader developer community. Writing “a stable ABI is an important milestone for the maturity of any language,” Swift engineer Jordan Rose’s blog post on Swift.org details just how the Swift team plans to implement. For developers, this is a very big deal. The good news is Swift’s ABI is currently stable for Swift 5 apps running on Apple platforms. To wit, that means the team has a successful beta build of Swift 5 with ABI stability, and is using it on beta tooling such as Xcode successfully. “As development of Swift on Linux, Windows, and other platforms matures, the Swift Core Team will evaluate stabilizing the ABI on those platforms,” Rose writes. A safe assumption is that, when Swift 5 launches with ABI stability, it will only do so for iOS, macOS, tvOS, and watchOS. The blog post doesn’t say as much, but it seems as though LSP support may throw a wrench into plans for ABI stability elsewhere. LSP, or Language Server Protocol, is a standard that allows a language to be used and compile in just about any IDE, for any platform that supports it. LSP support was added to SourceKit, so it will be used in Xcode, but that’s all within Apple’s purview. Outside influence is different; Microsoft may add Swift to Visual Studio via LSP, but ABI stability is a completely separate animal. The real ‘draw’ for most developers will be libraries – but this may also be Swift 5's biggest problem. Version 3 of the language was a hard turn for reverse compatibility; if you had a Swift 2 codebase, version 3 broke compatibility. Swift 5 may do the same for libraries. As Rose notes, Swift 5 libraries will work with any Swift version 5.0 or after without issue, but earlier language versions (version 4.2 is referenced directly) will need to run in ‘compatibility mode’ for Swift 5 libraries to work. It’s important to note ‘compatibility mode’ is the workaround that allowed most of the Swift version 3 code to compile and run alongside code from version 4 and later. Swift is also adding a feature named ‘library evolution support,’ which will help apps accessing a Swift 5 (or later) library. Today, whenever a Swift library changes, the app accessing it has to recompile. Moving forward, libraries written in Swift can be altered without the app accessing them. The same is true for frameworks, via a feature named ‘module stability’ for the compiler. Swift 5 won’t be the language's last major iteration, and it won’t alleviate all the headaches of the language. But it’s a huge step toward full maturity, and should give Objective-C holdouts a lot more reason to examine the language as a stable, viable option for their next app, service, framework, or library. Bumps in the road will always exist, but ABI stability for Swift 5 looks to be a version developers can use to accelerate through the last hairpin turn.