Run on Main Actor for Swift Packages

I'd like to know if there is a new property we can use in the definition of a Swift Package in the new Xcode 26, where we can set the whole package to run on Main Actor, as we have it in our apps for Xcode 26.

First, I'll start with a fully functioning Package.swift I have working:

// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

/// Feature toggles for conditional `SwiftSettings`.
///
/// Each feature corresponds to a compile-time flag that can be enabled or disabled
/// to customize how the package is built.
private enum Features: String, CaseIterable, Identifiable {
    case concurrency = "StrictConcurrency"

    var id: String { rawValue }

    /// Indicates whether the feature is enabled.
    /// When `true`, the corresponding SwiftSetting define will be added.
    var enabled: Bool {
        switch self {
        default:
            true
        }
    }

    func callAsFunction() -> SwiftSetting {
        .enableUpcomingFeature(self.id)
    }
}

private enum Experiments: String, CaseIterable, Identifiable {
    case `typed-throws` = "-enable-experimental-typed-throws"
    case `move-only` = "-enable-experimental-move-only"
    case `property-behaviors` = "-enable-experimental-property-behaviors"
    case `macros` = "-enable-experimental-macros"
    case `metatype-parameters` = "-enable-experimental-metatype-parameters"
    case `implementation-only-imports` = "-enable-experimental-implementation-only-imports"
    case `typed-global-actors` = "-enable-experimental-typed-global-actors"

    var id: String { rawValue }

    /// Indicates whether the feature is enabled.
    /// When `true`, the corresponding SwiftSetting define will be added.
    var enabled: Bool {
        switch self {
        default:
            true
        }
    }

    func callAsFunction() -> SwiftSetting {
        .unsafeFlags([self.id])
    }
}

/// Compile-time macro toggles for known conditional defines.
///
/// This enum controls macro definitions that influence build behavior,
/// such as disabling playground-related macros that conflict with strict concurrency.
private enum Definitions: String, CaseIterable, Identifiable {
    // The playground-related macro is currently affecting system
    // versions of Tahoe beta 4, and is broken with strict-concurrency.
    case playgrounds = "PLAYGROUNDS"

    var id: String { rawValue }

    /// Indicates whether the macro definition is enabled.
    /// If enabled, the corresponding SwiftSetting define will be added.
    var enabled: Bool {
        switch self {
        case .playgrounds:
            false
        @unknown default:
            true
        }
    }

    /// Specifies the build setting condition under which the macro should be applied.
    /// Allows fine-tuning of when the define is active (e.g., by platform, configuration, or traits).
    var when: BuildSettingCondition {
        switch self {
        case .playgrounds:
            .when(
                platforms: .none,
                configuration: .none,
                traits: []
            )
        @unknown default:
            .when(configuration: .debug)
        }
    }

    func callAsFunction() -> SwiftSetting {
        .define(self.id)
    }
}

/// The Swift settings applied to all targets, derived from feature and macro toggles.
///
/// Initially includes default isolation for the `MainActor`, then conditionally appends
/// defines for enabled features and macros.
private var settings: [SwiftSetting] = [
    .defaultIsolation(MainActor.self),
    .strictMemorySafety(),
    .swiftLanguageMode(.version("6.2")),
]

for feature in Features.allCases {
    guard feature.enabled else { continue }

    settings.append(feature())
}

/// Append `SwiftSetting` define flags.
///
/// Only definitions that are **enabled** *and* satisfy their `.define` will
/// be added.
for definition in Definitions.allCases {
    guard definition.enabled else { continue }

    settings.append(definition())
}

/// The main package declaration for ``Shell``.
public let package = Package(
    name: "example-swiftui-package",
    platforms: [
        .macOS(.v26)
        // .iOS(.v26),
        // .visionOS(.v26),
        // .tvOS(.v26),
        // .watchOS(.v26),
        // .macCatalyst(.v26),
    ],
    products: [
        .library(
            name: "Example",
            targets: ["Example"]
        ),
        .executable(
            name: "Executable",
            targets: ["Executable"]
        ),
    ],
    dependencies: [
        .package(url: "https://github.com/apple/swift-log.git", branch: "main")
    ],
    targets: [
        .target(
            name: "Example",
            dependencies: [],
            exclude: [],
            resources: [],
        ),

        .executableTarget(
            name: "Executable",
            dependencies: [
                "Example",
                .product(name: "Logging", package: "swift-log"),
            ],
        ),
        .testTarget(
            name: "Example-Tests",
            dependencies: ["Example"]
        ),
    ],

    swiftLanguageModes: [
        .version("6.2")
    ],
)

// MARK: - Settings -

/// Apply the collected `SwiftSettings` to every target in the package.
///
/// This ensures that all targets respect the common feature and macro toggles,
/// including strict concurrency enforcement and other compile-time flags.
for target in package.targets {
    target.swiftSettings = settings
}

Now, I'm relatively new to the Apple world of development, but certainly not to development in general; I apologize if there are some anti-patterns or odd practices here.

Okay, narrowing the code down to the important section:

/// The Swift settings applied to all targets, derived from feature and macro toggles.
///
/// Initially includes default isolation for the `MainActor`, then conditionally appends
/// defines for enabled features and macros.
private var settings: [SwiftSetting] = [
    .defaultIsolation(MainActor.self),
    .strictMemorySafety(),
    .swiftLanguageMode(.version("6.2")),
]

Note the .defaultIsolation[...] -- this is where you'll be able to run on the MainActor. This type is a [SwiftSetting], so go ahead and add where applicable in the Package instance.

Hope this helps!

Run on Main Actor for Swift Packages
 
 
Q