Hive
[swift_package] .defaultIsolation in swiftSettings is not passed to swiftc
GitHub issue · Open
Hi! I’m trying out Once on a Swift 6 project and ran into an issue with actor isolation settings.
When a Swift package target defines .defaultIsolation(MainActor.self) in its swiftSettings, the setting doesn’t seem to be forwarded to swiftc (the -default-isolation MainActor flag is missing). As a result, the build fails under Swift 6 with concurrency errors on global or static variables that rely on default isolation.
Environment: Xcode 27, Swift 6.4, Once 0.56.0.
Reproduction
Package.swift:
// swift-tools-version: 6.2
import PackageDescription
let package = Package(
name: "DefaultIsolationRepro",
platforms: [.macOS(.v14)],
targets: [
.target(
name: "DefaultIsolation",
swiftSettings: [
.defaultIsolation(MainActor.self)
]
)
]
)
Sources/DefaultIsolation/DefaultIsolation.swift:
public final class MutableBox {
public var value: Int
public init(value: Int = 0) {
self.value = value
}
}
public enum GlobalState {
public static let shared = MutableBox()
}
Steps
Native SwiftPM builds fine:
swift build
Building the same target with Once:
once query targets
once build SwiftPackage_DefaultIsolationRepro_DefaultIsolation
Fails with:
Sources/DefaultIsolation/DefaultIsolation.swift:10:21: error: static property 'shared' is not concurrency-safe because non-'Sendable' type 'MutableBox' may have shared mutable state [#MutableGlobalVariable]
public static let shared = MutableBox()
^
swift_module_compile_DefaultIsolation (2) failed for SwiftPackage_DefaultIsolationRepro_DefaultIsolation with exit code 1
When checking the swiftc command:
- Native
swift buildpasses-default-isolation MainActor once buildpasses-swift-version 6, but-default-isolation MainActoris missing
Investigate, reproduce, or fix this item in an isolated repository. Each Flight preserves its outcome and agent session.
Start a Flight and preserve its objective, outcome, and session here.
No GitHub comments yet.