Apple: Programming language Swift 5.2 is out – Xcode 11.4 and faster code completion

Apple releases Swift 5.2 with improved compiler diagnostics and a more efficient compiler.
Written by Liam Tung, Contributing Writer

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. 

SEE: It's all about the ports: What Apple needs to change now that Jony Ive is gone

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.

More on programming languages

  • Programming language Julia: Version 1.4 is even faster and brings these new features  
  • Oracle: Programming language Java 14 is out with these 16 major feature improvements  
  • Microsoft: We won't evolve Visual Basic programming language but we'll open it to .NET 5  
  • New programming language rankings: Python now as popular as Java, as TypeScript climbs
  • Programming languages: Java developers flock to Kotlin and ditch Oracle JDK for OpenJDK  
  • Programming language popularity: Apple's Objective-C tumbles down the rankings  
  • Programming languages: Go and Python are what developers most want to learn  
  • Know Python language and up for a 'hardcore' coding test? Get in touch, says Tesla  
  • Java or C++, Full stack or Front end: The programming languages and developer jobs that pay you the most  
  • Developers love Rust programming language: Here's why  
  • Google reveals new Python programming language course: Scholarships for 2,500  
  • Microsoft boosts programming language Python's popular VS Code extension  
  • Programming language of 2019? Python beaten by trusty old C  
  • Programming language Python's popular extension for Visual Studio Code revamped  
  • Programming language Python 2.7 code is now frozen: Last release coming in April  
  • Netflix: Our Metaflow Python library for faster data science is now open source  
  • Microsoft: We're creating a new Rust-like programming language for secure coding 
  • Tech jobs: Python programming language and AWS skills demand has exploded  
  • Python programming language creator retires, saying: 'It's been an amazing ride'
  • Programming languages: How Instagram's taming a multimillion-line Python monster
  • Salesforce: Why we ditched Python for Google's Go language in Einstein Analytics  
  • Google: Take our free Kotlin programming language courses to build Android apps
  • Microsoft: We want you to learn Python programming language for free
  • JPMorgan's Athena has 35 million lines of Python code, and won't be updated to Python 3 in time TechRepublic
  • Mozilla's radical open-source move helped rewrite rules of tech CNET
  • Editorial standards