Swift 5.5, the latest version of Apple-developed language intended to replace C-based languages, has been published with capabilities centering on concurrency and package collections.Described in a September 20 bulletin as a “massive release,” Swift 5.5 can be accessed from swift.org. The release offers concurrency interoperability with Swift predecessor Objective-C, a proposal that bridges Swift concurrency features and the convention-based expression of asynchronous functions in Objective-C. The goal is to allow asynchronous Objective-C APIs to be immediately usable with Swift’s concurrency model.Although modern Swift development involves a lot of async programming, the APIs have been hard to use, the project notes. An async/await capability in Swift 5.5 defines the semantics for asynchronous functions. This proposal is intended to make the whole process more natural and less error-prone. Swift async/await also can be used to write and use functions that return many values over time. This work was done via the Async/Await Sequences proposal.Another new feature, structured concurrency, is described in release notes as enabling concurrent execution of asynchronous code with a model that is ergonomic, predictable, and admits efficient implementation.Other new capabilities in Swift 5.5:
For the Swift Package Manager (SwiftPM), the concept of Package Collections is introduced to the package ecosystem. Collections are authored as static JSON documents and contain a list of packages and additional metadata per package. These are published to a web server or CDN-like infrastructure. SwiftPM gains a new command-line interface for adding and removing collections and will index them in the background, enabling users to more easily discover packages in the collections.
Actors are introduced. An actor serves as a reference type (actor) that protects access to its mutable state.
Property wrappers, introduced in Swift 5.1 to abstract away common accessor patterns for properties, are being extended to function parameters and closure parameters. Previously, this capability was limited to local variables and type properties.
Copyright © 2021 IDG Communications, Inc.
Source link