What's New in Swift 6.0: Data-Race Safety, Typed Throws and More

Updated November 2026. This post now describes Swift 6's concurrency checking accurately and fixes the noncopyable-types example. Swift 6.2 has since made strict concurrency much easier to live with; see Swift 6.2's approachable concurrency in SwiftUI apps.

Swift 6.0 shipped with Xcode 16 in September 2024. Its headline is the Swift 6 language mode, which turns data races into compile-time errors, but it also brought a handful of smaller features you'll use every day.

Data-race safety in the Swift 6 language mode

In the Swift 6 language mode, the compiler proves that no mutable state can be reached from two concurrency domains at once. What used to be warnings under "strict concurrency checking" in Swift 5 mode are now errors. The compiler checks three things:

// Not Sendable: a class with mutable state.
final class DownloadStats {
    var bytes = 0
}

func track() {
    let stats = DownloadStats()
    Task.detached {   // error: sending value of non-Sendable type risks causing data races
        stats.bytes += 1
    }
    print(stats.bytes)   // ...because 'stats' is still used here
}

Swift 6 is smarter than "non-Sendable never crosses": with region-based isolation, handing a value to another task is fine as long as you don't touch it again afterwards. Delete the print and this compiles.

The usual fixes are to make the type an actor, isolate it to the main actor, or make it a value type:

@MainActor
final class DownloadStats {
    var bytes = 0
}

@MainActor
func recordChunk(_ stats: DownloadStats, size: Int) {
    stats.bytes += size   // fine: everything here runs on the main actor
}

You can adopt the Swift 6 language mode one module at a time; Swift 5 mode modules keep compiling with the same compiler.

Typed throws

A function can now declare exactly which error type it throws. Callers then get that concrete type in catch instead of any Error, and no existential boxing is needed, which matters in embedded and performance-sensitive code.

enum NetworkError: Error {
    case badURL
    case requestFailed(status: Int)
}

func fetchData(from string: String) throws(NetworkError) -> Data {
    guard URL(string: string) != nil else { throw .badURL }
    throw .requestFailed(status: 503)
}

do {
    let data = try fetchData(from: "https://example.com")
    print(data.count)
} catch {
    // error is NetworkError here, not any Error
    switch error {
    case .badURL: print("Bad URL")
    case .requestFailed(let status): print("Failed with \(status)")
    }
}

Use typed throws when the set of errors is genuinely closed. For most app code, untyped throws is still the better default.

count(where:)

Counting matching elements no longer needs filter and an intermediate array:

let numbers = [1, 2, 3, 4, 5, 6]
let evenCount = numbers.count(where: { $0.isMultiple(of: 2) })   // 3

Noncopyable types

Types can opt out of being copyable with ~Copyable. A noncopyable value has exactly one owner; passing it with consuming moves it, and the compiler rejects any use after that. This models resources like file handles or one-time tokens, where a copy would be a bug. Swift 6.0 extended them to work with generics, so Optional and your own generic types can hold them.

struct SingleUseToken: ~Copyable {
    let value: String

    consuming func redeem() -> String {
        value   // after this, the token is gone
    }
}

func checkout() {
    let token = SingleUseToken(value: "abc123")
    print(token.redeem())
    // print(token.redeem())   // error: 'token' used after consume
}

128-bit integers

Int128 and UInt128 are now standard library types (on Apple platforms they need iOS 18, macOS 15 or later):

let large: Int128 = 170_141_183_460_469_231_731_687_303_715_884_105_727
print(large)   // Int128.max

Access levels on imports

Imports can carry an access level, so a dependency used only inside your module doesn't leak into your public API:

public import Foundation      // types appear in this module's public API
internal import Networking    // used only inside this module
private import Analytics      // used only in this file

Conclusion

Swift 6.0's lasting change is the language mode: data races became compile errors. The cost was a lot of annotations in UI code, which Swift 6.2 has largely removed with main-actor-by-default modules. Typed throws, count(where:), noncopyable types and import access levels are smaller, but they make everyday code clearer.

For the full list of proposals, see Swift.org's Swift 6 announcement.

Building a SwiftUI app with an AI coding agent? Effect UI gives it a design system to follow, so the screens it writes look designed.

More from the blog

DESIGN.md for iOS: Give Your AI Coding Agent a Design System

What a DESIGN.md is, what goes in one for a SwiftUI app (tokens, type, spacing, motion and rules) and how to make Claude Code, Cursor or Codex follow it on every screen.

Liquid Glass in SwiftUI: A Practical Guide for iOS 26

How to use Liquid Glass in SwiftUI on iOS 26: glassEffect, tint and interactive glass, GlassEffectContainer, morphing with glassEffectID, glass button styles and fallbacks.

Swift 6.2 Approachable Concurrency in SwiftUI Apps

Swift 6.2 makes strict concurrency practical for app code: main-actor isolation by default, nonisolated async functions that stay on the caller's actor, @concurrent and isolated conformances.