What's New in Swift WWDC26

  • Everyday Ergonomics
  • Libraries
  • Full-stack Swift
  • Performance Ergonomics
  • Open source development

Everyday Ergonomics

In Swift 5.6 you needed parentheses to make a protocol type optional with any or some. That limitation has now been lifted.

BeforeAfter
Optional any/some — beforeOptional any/some — after

There is a new warning when an error goes unhandled inside a Task.

Unhandled error warning in Task

The restriction on calling asynchronous functions inside defer blocks has been lifted.

BeforeAfter
Async in defer — beforeAsync in defer — after

In your codebase you have probably seen the weak var pattern where var wasn't actually needed (a let would have done) but was used only so you could mark it weak. In Swift 6.2 Apple finally lets us write weak let — and doing so also allows the type to conform to Sendable. Two birds with one stone.

weak let

There is new syntax to opt out of a protocol or type — a way to say "not this type". The example below says "not Sendable".

Opting out of a protocol

Marking a subclass as not conforming to a protocol does not stop its own child classes from conforming to that protocol.

Child classes can still conform

Previously, for types that had both internal and private properties, you had to write a private initializer and an internal initializer yourself. Now the Swift compiler generates both for you.

Compiler-generated initializers

There is a new availability marker, anyAppleOS, for specifying version availability across all Apple platforms at once in your availability checks.

BeforeAfter
anyAppleOS — beforeanyAppleOS — after

On top of this default you can add exclusions by marking any of the platforms unavailable, or giving it a different version constraint.

Adding platform exclusions

This also applies to #-guarded code, to exclude code from compiling entirely.

Excluding code with #if

There is a new @diagnostic declaration attribute that lets you silence or adjust compiler warnings gradually. It is quite useful — you can read more about it in the proposal: Source Warning Control.

Silencing warnings

Silencing warnings

Enabling a Swift concurrency feature for specific functions

Enabling concurrency for a functionEnabling concurrency for a function

There is a new module operator, similar to C. Previously you wrote Module.Type; you can now write Module::Type. This is especially useful when there is a type with the same name as a module and the compiler can't tell where to resolve the type from — in general, the dot syntax could mean either a type nested in another type or a module member.

Module operatorModule operator
import Rocket
import GiftShopToys

let rocket2 = Rocket.SaturnV()   // ambiguous — prefers Rocket module's Rocket.SaturnV
let rocket3 = Rocket::SaturnV()  // unambiguous — definitely Rocket module's SaturnV

There is a new task-cancellation shield block, withTaskCancellationShield, to perform an operation you want to run even when the task is being cancelled — for example, closing a connection to a database.

withTaskCancellationShield

There is a new map-over-key-value function on dictionaries, to map over a dictionary and form a new one.

BeforeAfter
Mapping over a dictionary — beforeMapping over a dictionary — after

There is also a unified file path that works across platforms.

Unified cross-platform file path

Improvements to Swift Testing

You can now define the severity of an issue, rather than treating everything as a failure — test issues can be marked as warnings too.

Issue severity in Swift Testing

You can also cancel a test midway, which is helpful for skipping a test for certain parameters.

Cancelling a test midway

There are new arguments on the swift test command to repeat a test.

Repeating a test

XCTest and Swift Testing interoperability

XCTest assertions now surface as Swift Testing issues when run from swift test.

XCTest assertions as Swift Testing issues

#expect now works inside XCTest class-based test functions.

#expect in XCTest

You need to opt in for these behaviors.

Opting in

There is more on migrating from XCTest to Swift Testing in the session: Migrate to Swift Testing.

Subprocess

The Subprocess Swift package, open sourced in 2025, has been bumped to version 1.9 with new features.

Subprocess 1.9

It can stream process output using AsyncStream.

Streaming process output with AsyncStream

Updates to the Foundation library

Foundation adds ProgressManager, a native solution for progress tracking and observation.

Reporting progress

Reporting progress

Observing progress

Observing progress

It can also attach additional metadata (such as deltaV) to a Subprocess in a type-safe way.

Attaching type-safe metadata

Foundation is faster now, thanks to optimizations to sequences, using Span in for loops, reduced bridging between NSData and Data, and NSURL and CFURL now sharing the same implementation.

Full-stack Swift

You can now expose Swift functions to C and call them using @c, similar to @objc.

@c interop

There is new Swift–Java interoperability using the swift-java package.

swift-java

A demo of calling Swift functions from Kotlin using swift-java:

Calling Swift from Kotlin

There is also a new Swift SDK for Android.

Updates to the VS Code Swift extension

It now works with the swiftly CLI, letting you choose a toolchain right from VS Code.

Choosing a toolchain with swiftly

It also supports previewing DocC documentation in VS Code.

Previewing DocC in VS Code

There is WASM support in Swift, along with updates to JavaScript interoperability.

There was also a mention of Goodnotes, a Singapore startup that built their entire app — iOS, Android, web, and even the backend — in Swift. For the web UI they used WASM.

Goodnotes built on Swift

For updates to embedded Swift, watch from this timestamp: Embedded Swift.

Performance Ergonomics

You get more control over compiler inlining. (To learn more about inlining, read Inlining and outlining in Swift.)

Control over inlining

There is also explicit specialization. In simple terms, you ask the compiler to generate a typed version of your generic function. The compiler already does this a lot of the time when it has visibility into the codebase, but for libraries you may want to add @specialized to a generic function for the types you know it is most used with — this removes the overhead of the witness table. (To understand this better, read the proposal: Specialized.)

Explicit specialization

There is a replacement for the UnsafePointer approach to sharing storage and avoiding unnecessary copies, with the introduction of sending and borrowing. (Read more in the proposal: Parameter ownership modifiers. I also liked this article, which explains the concept with examples.)

sending and borrowing

One great point from the Swift team, worth re-iterating: Swift makes it easy to write good, performant code, and makes it possible to write the most performant code.

Easy and possible

The Equatable, Comparable, and Hashable protocols can now be used on noncopyable and nonescapable types.

Protocols on noncopyable typesProtocols on noncopyable types

Associated types can now be noncopyable or nonescapable too.

Noncopyable associated types

In Swift 6.4, the for loop uses the same Iterable protocol mentioned above in place of the previous Sequence protocol.

for loop using Iterable

The new Iterable accesses elements in batches of a Span rather than one by one, which improves the for loop in Swift 6.4.

Iterating in batches of Span

There is also a new set of safe replacements for unsafe APIs.

Safe replacements for unsafe APIs

Open source development

There is a new open source build system, Swift Build, that will power both Xcode and SwiftPM.

Swift Build

There are also new Swift workgroups for making open source contributions to the Swift language: