What is the default isolation mode for Swift packages (6.2+)?

While watching Doug's talk on Concurrency at Embracing Swift concurrency - WWDC25 - Videos - Apple Developer, I went looking for how someone might enabled "main actor mode" in terms of isolation defaults in Package.swift - outside of Xcode.

I found defaultIsolation(_:_:) | Apple Developer Documentation, but it doesn't specify what the default mode is for packages built under Swift 6.2 that don't specify it. I thought I remember hearing somewhere that this is an "opt-in" scenario — is the default 'nil' if a package doesn't specify it?

Ah, this is specified in the proposal, but we should lift it to the documentation of defaultIsolation as well:

When no .defaultIsolation setting is specified, the default isolation within the module is nonisolated .

2 Likes

There's a smidge of discordance there in what PackageDescription has today - it current asserts the only values allowed are either MainActor.self or nil - probably best to assert that nil is both the default, and results in classes being inferred as nonisolated by default.

I'll wrangle a PR to make an update for that. Is there a section of the migration guide (or TSPL) that would be worthwhile to link to "for more information"?

1 Like