This year’s “What’s new in Swift” included a plethora of improvements and new add-ons. Some of the news are:

  • better diagnostic compiler error’s and hence better debugging
  • improved and faster code completion
  • improved auto indentation
  • improved integration
  • improved handling of chained method calls and property accesses
  • A standardized way to delegate a program’s entry point with the @main attribute
  • Swift Numerics, an open source project bringing additional support for numeric functions to Swift
  • Swift Argument Parser, build your command line tools with Swift
  • where clauses on contextually generic declarations
  • Multi-Pattern catch clauses
  • Float16

But the list is much longer. In the following are some highlights for what is to come with Swift 5.3 and you can find a list of further reading and related videos at the bottom of the post.

Additional Cross Platform Support and Swift AWS Lambdas

To support the Swift ecosystem Apple has added additional cross-platform support and will officially support:

  • All Apple platforms
  • Ubuntu 16.04, 18.04, 20.04
  • CentOS
  • Amazon Linux 2
  • Windows (coming from Swift 5.3)

This also opens up for official support for Swift AWS Lambdas. The AWSLambdaRuntime package is based on SwiftNIO and allows for both closure based Lambdas and eventloop Lambda functions. Below is an example of a closure based Lambda as presented in the talk:

import AWSLambdaRuntime { (_, name: String, callback) in
    callback(.success("Hello, \(name)!"))

Enum Improvements

This year we get two big improvements to the enum type:

Synthesized Comparable Conformance For enum Types

With Swift 4.1 came synthesized, opt-in enum conformance for Equatable and Hashable, however conformance to Comparable was left out. From Swift 5.3 Comparable will also be included, allowing for easy sorting by the order of declaration. The synthesized, opt-in conformace only comes for enums without raw values, without associated types or with comparable associated types.

enum ApplePlatform: Comparable {
    case iOS
    case ipadOS
    case macOS
    case tvOS
    case watchOS

[ApplePlatform.watchOS, ApplePlatform.ipadOS, ApplePlatform.macOS].sorted()
// [ApplePlatform.ipadOS, ApplePlatform.macOS, ApplePlatform.watchOS]

Enum Cases As Protocol Witnesses

Another great improvement to enums in Swift is the possibility to allow for static protocol requirements to be witnessed by an enum case. It introduces two rules:

  1. static, get-only protocol requirement can be witnessed by an enum case without an associated value
  2. static func requirement can be witnessed by an enum case with one or more associated values
protocol ErrorReportable {
    static var notFound: Self { get }
    static func invalid(searchTerm: String) -> Self

enum UserError: ErrorReportable {
    case notFound
    case invalid(searchTerm: String)

Multiple Trailing Closures

If you have been following along in the discussions on Swift forums, you may have come across the topic of multiple trailing closures. It has been thoroughly discussed and many people had their opinions on both the syntax and the final process.

Up until now it has only been possible to use a trailing closure if your method has one escaping closure. An example of that is one of the animate methods in UIKit

import UIKit
UIView.animate(withDuration: 0.3) {
    self.view.alpha = 0

If we instead wanted to use the animate method that also allows us to define what should happen at completion we can’t use trailing closures anymore

import UIKit
    withDuration: 0.3, 
    animations: { self.view.alpha = 0 },
    completion: { _ in 

With Swift 5.3 any method can now have multiple trailing closures. The first closure will be without a label, while all remaining closures should be labeled. The animate method from before will now look like:

import UIKit
UIView.animate(withDuration: 0.3) { 
    self.view.alpha = 0 
} completion: { _ in 

Increased Availability of Implicit self in Closures

Swift requires the explicit use of self in escaping closures which capture it. This can lead to a lot of repetitive code. With implicit self in closures in Swift 5.3, we can omit all self. inside our closures. Instead we can add self to the capture list of the closure. Using implicit self will then update our animate method from before, so we only have to specify self once in each closure.

import UIKit
UIView.animate(withDuration: 0.3) { [self] in
    view.alpha = 0 
} completion: { [self] _ in 

Other WWDC Articles

Resources and Further Reading

Article Photo - capture from What’s new in Swift by Apple


Heidi Puk Hermann

Vapor Developer

👩🏼‍💻 Physicist turned teacher turned developer... Passionate about learning and teaching

You may also like

How to setup CI/CD for iOS App Development with Fastlane, CircleCI and Firebase App Distribution

App developers always strive to improve the product they are working on. So it is definite that either(mostly) you will be adding new features to existing products or (luckily) you will be setting up a whole new project. Either way, onboarding new developers or bootstrapping an entirely new project is...

RubyKaigi Takeout 2021: A Look Back

Can you believe it’s already been an entire year since I had the opportunity to join my first ever developers conference, the RubyKaigi? Over the past three days, I was blessed with the opportunity to also enjoy this year’s talks and sessions, and get once again the opportunity to immerse...