pylapp

expect

What's new Swift?

πŸ‡ΊπŸ‡Έ – Monday, May 12th 2025

Keywords: #Swift, #Swiftlang, #iOS, #iOSDev, #Apple

Here are some summaries of main news about Swift, just to keep them in mind and list (more detailed) sources. A lof of this content is written thanks to the awesome work of Hacking with Swift. If you consider supporting this publication, prefer supporting them instead.

Swift 6.1 (2025)

Concurrency has been updated. Now the nonisolated keyword, used to indicate that an API is safe to call from any concurrent context, can be used for types and extensions ; it prevents for example to add the keyword for every properties or methods in extensions.

Trailing comas can be added at the end of tuples, argument lists and string interpolations for example ; not only in collection literals.

Package traits can now be defined inside Package.swift definitions so as to define configurations for specific environments like WASM.

Swift Testing has been improved with custom traits to perform logic before or after tests (e.g. for set-up and tear-down actions). Test scopes can be customized, for example for mocks usages. #expect(throws:) and #require(throws:) have been improved also.

Swift-DocC provides better management of references of methods with same signatures.

Sources

Swift 6 (2024)

Concurrency comes! Now, if enabled, we can use the power of concurrency and its new API to ensure the source code is thread-safe with improved memory safety and no more data races.

Typed throws are now available. Methods in their signatures can define which types of errors are thrown, and it brings better clarity and consistancy.

Ownership provided with Swift 5.9 has a bit been improved and can be applied to generics.

C++ interoperability has been improved with support of move-only types, virtual methods, default arguments and also more standard library type.

Embedded Swift is included as preview with Swift 6 ; this toolchain supports ARM and RISC-V.

128-bit integers are now managed in their signed and unsigned variants.

@DebugDescription is now available for custom LLDB summaries ; this new macro let specify LLDB type summaries for our own types in the code to ease debugging.

Foundation has been refactored with some API converted to Swift like JSONDecoder, URL, Calendar, FileManager, ProcessInfo, FormatStyle, ParseStrategy, Predicate, JSON5.

Swift Testing exists! Expressive API, more simple to use compared to XCTest, scales large codebases with features like parameterization.

Sources

Swift 5.9 (2023)

Macros can be used to reduce repetitive boilerplate and work just like built-in language features. They are based on SwiftSyntax.

Parameter packs with generics syntax allow to define one method signature with an undefined list of parameters, without upper limits, even for returned values.

Ownership is featured. The new consume operator tells Swift to deinitialize a variable and transfer its contents without copying it. The borrow operator comes too, and structs and enums can be defined as noncopyable. The discard keyword is also here for consuming methods of elements having a deinit to bypass.

Syntax has been improved with the if and switch more modernized in their available syntaxes.

Sources

Swift 5.8 (2023)

It prepares for the Swift 6 big changes and its upcoming features. Developer experience has been improved.

@backDeployed is available and makes possible to allow new API to be used in older versions of frameworks by writing code for a function into app's binary then performing a runtime check.

implicit self for weak self captures is a reality and makes for example guard let else syntax smoother.

It is also possible to have functions with generic parameter which can be optional on the parameter definition.

Collection downcasts in cast patterns are supported and can be useful for example with switch case let as pattern.

Resources

Swift 5.7 (2022)

if let for unwrapping optionals is now shorter.

Regex has been enriched a lot with DSL for example.

Opaque parameter declarations and result types can be managed with the use of some keyword in parameter declarations.

Sources

Swift 5.6 (2022)

any keyword is available to mark existential types, which is different than opaque types with some keyword. The any keyword is here to bring optimization when objects are used through their abstract types making the runtime use the dynamic dispatch process for optimization. Thus this process won't be used.

Type placeholder with _ symbol can be called to let the compiler define types of variables (in, for example, declarations).

Concurrency has been enriched to prepare Swift 6 with the @preconcurrency macro and other improvements with @Sendable and @MainActor.

Sources

Swift 5.5 (2021)

async/await and async/throws are now real! Here come asynchronous functions, allowing to run complex asynchronous code without for example needing to use in some cases Combine. Task is also shipped.

AsyncSequence come with async/await also.

Actors are also embedded, i.e. kind of classes that are safe to use in concurrent environments with their content accessible by a single thread at any given time.

Sendable are here to define if data can safely be transferred to another thread.

lazy has been improved to be used in local contexts and write stored properties only calculated when first used.

Sources

β€” Last update: Monday, May, 12th 2025 β€”

Did you enjoy reading this blog? Give me a beer 🍺 or use something else ❀️‍πŸ”₯ Licensed under CC-BY-SA 4.0. Opinions are my own. To contact me, feel free to choose the most suitable medium for you, or for example Mastodon.