Apple has released version 5.2 of its widely used Swift programming language for writing apps for the Mac, iPad, iPhone, Apple Watch, and Apple TV.
Apple's open-source Swift 5.2 programming language arrived with Tuesday's release of Xcode 11.4, the latest version of Apple's integrated development environment (IDE). Swift 5.2 builds on Swift 5.1, released in September, and Swift 5 from March 2019.
Xcode 11.4 lets developers distribute macOS apps as a 'universal purchase' with the iOS version of the same app. Once developers adopt this, it will allow users to make a single in-app purchase that applies to macOS, iOS, iPadOS, watchOS, and tvOS devices.
The prospect of universal purchases for macOS is a lure for developers to build apps with Mac Catalyst, Apple's platform to help developers bring iPadOS apps across to its 100 million Mac users. Universal purchase is enabled by default for new Mac Catalyst apps created in Xcode 11.4.
SEE: How to build a successful developer career (free PDF)
According to Ted Kremenek, a member of the Swift Core Team, Swift 5.2 "drastically" improves compiler diagnostics with better quality and more precise error messages.
It also offers faster code completion, increased reliability in debugging, improved handling of dependencies in the Swift Package Manager, and tooling improvements with Language Server Protocol (LSP) and SwiftSyntax.
Swift 5.2's code-completion feature works up to 1.2- to 1.6-times faster for large files compared with Xcode 11.3.1, according to Kremenek.
Swift 5.2's new compiler diagnostics engine addresses potentially confusing error messages flagged in code in Swift 5.1 and is now better at pinpointing the exact piece of code that needs fixing.
It also promises more efficient creation of incremental builds, the mode in Xcode for compiling builds to debug a Swift project.
"To minimize the wasted work done by Incremental mode builds, the Swift 5.2 compiler – notably the type checker – leverages a new centralized logic for caching, lazy evaluation, and dependency tracking between requests, where a request is a self-contained unit of computation," notes Kremenek.
"This logic is now used by the compiler to more efficiently resolve declarations and their references to one another."
Kremenek suggests other performance optimizations to Swift 5.2's compiler behavior should also improve Xcode's Whole Module mode, which is used for release builds.
LLDB, the open-source and default debugger in Xcode, is now better at reconstructing type information for Swift programs from debug information.
LLDB can also now import C and Objective-C types from debug information in the DWARF format, instead of compiling the Clang module from source code, notes Kremenek.
The Swift Package Manager in Swift 5.2 improves resolution for package dependencies. These should reduce the chance of dependency version conflicts and improve the quality of error messages, while also offering better performance in complex package graphs.
Finally, there are updates to the SourceKit-LSP implementation of the Language Server Protocol (LSP) for Swift and C-based languages. Microsoft created LSP, a client-server protocol, to integrate features such as auto complete.
Xcode 11.4 and its Command Line tools package include Swift 5.2 SourceKit-LSP, which now supports the FixIts LSP feature so that Swift errors, warnings, and notes with FixIts are supported using LSP's Code Actions.
Swift now also supports LSP local refactoring, meaning Swift local factorings such as extract-to-method are now supported using the 'Refactoring' Code Action kind, according to Kremenek.