What’s new in v5.2

Swift 5.2 adds language changes and clearer error messages

Maika Möbus
Swift 5.2
© Shutterstock / Sokolov Alexey

The programming language Swift is now available in version 5.2, and it has several new features on board. Two language proposals have been implemented, error messages should now show more detailed information and code completion speed should be improved.

Swift 5.2 has been released. The general-purpose programming language, developed by Apple, was introduced in a keynote in 2014: “The language is called Swift and it totally rules.”

A year later, the language was open sourced. With its focus on speed, Swift should serve as a replacement for C, C++ and Objective-C. Let’s dive right in and see what’s new in v5.2.

SEE ALSO: COVID-19 vs open source: How developers are fighting the virus

Features in Swift 5.2

Swift 5.2 implements two language proposals. Both are additive changes, which means they have no impact on API resistance, source compatibility or ABI stability.

The first proposal, SE-0249, means Swift users can now use the key path expression \Root.value wherever (Root) -> Value functions are allowed. SE-0253 introduces “statically” callable values to Swift. This can, for example, be useful for values that represent mathematical functions or function expressions.

In the latest version, Swift users should also notice some developer experience improvements. The compiler diagnostics—errors and warnings—should now show more information.

For example, this code tries to compare an enum value with a case that doesn’t exist:

enum E { case one, two }

func check(e: E) {
  if e != .three {

The error message in Swift 5.1 isn’t clear about where the problem lies:

error: binary operator '!=' cannot be applied to operands of type 'E' and '_'
  if e != .three {
     ~ ^  ~~~~~~

Swift 5.2, on the other hand, tells you exactly what went wrong:

error: type 'E' has no member 'three'
  if e != .three {

Another aspect of the compiler diagnostics has also received an upgrade: Unnecessary type checking has been removed, which should increase the speed of code completion.

Further updates in Swift 5.2 refer to debugging, the handling of dependencies in the Swift Package Manager, LSP and SwiftSyntax.

SEE ALSO: Progressive React Apps

Swift 5.2 is available for Apple platforms, where it ships with the macOS IDE Xcode in version 11.4, and for Linux.

See the release notes for more information.

Maika Möbus
Maika Möbus has been an editor for Software & Support Media since January 2019. She studied Sociology at Goethe University Frankfurt and Johannes Gutenberg University Mainz.

Inline Feedbacks
View all comments