diff --git a/.github/workflows/containerization-build-template.yml b/.github/workflows/containerization-build-template.yml index 0636a7a1..b57f85d8 100644 --- a/.github/workflows/containerization-build-template.yml +++ b/.github/workflows/containerization-build-template.yml @@ -22,7 +22,6 @@ jobs: contents: read packages: write env: - CURRENT_SDK: y DEVELOPER_DIR: "/Applications/Xcode_26.b1.app/Contents/Developer" steps: diff --git a/Package.swift b/Package.swift index db7f5237..0651bcaf 100644 --- a/Package.swift +++ b/Package.swift @@ -21,14 +21,6 @@ import CompilerPluginSupport import Foundation import PackageDescription -let settings: [SwiftSetting] -if ProcessInfo.processInfo.environment["CURRENT_SDK"] != nil { - // TODO: Remove this compile condition when the updated macOS SDK is available publicly - settings = [.define("CURRENT_SDK")] -} else { - settings = [] -} - let package = Package( name: "containerization", platforms: [.macOS("15")], @@ -77,8 +69,7 @@ let package = Package( ], exclude: [ "../Containerization/SandboxContext/SandboxContext.proto" - ], - swiftSettings: settings + ] ), .executableTarget( name: "cctl", diff --git a/Sources/Containerization/NATNetworkInterface.swift b/Sources/Containerization/NATNetworkInterface.swift index d5dbdac9..ed5e833c 100644 --- a/Sources/Containerization/NATNetworkInterface.swift +++ b/Sources/Containerization/NATNetworkInterface.swift @@ -20,45 +20,44 @@ import vmnet import Virtualization import ContainerizationError import Foundation -import Synchronization +import SendableProperty /// An interface that uses NAT to provide an IP address for a given /// container/virtual machine. @available(macOS 26, *) public final class NATNetworkInterface: Interface, Sendable { public var address: String { - get { state.withLock { $0.address } } - set { state.withLock { $0.address = newValue } } + get { state.address } + set { state.address = newValue } } public var gateway: String { - get { state.withLock { $0.gateway } } - set { state.withLock { $0.gateway = newValue } } + get { state.gateway } + set { state.gateway = newValue } + } + + @available(macOS 26, *) + public var reference: vmnet_network_ref { + state.reference } public var macAddress: String? { - get { state.withLock { $0.macAddress } } - set { state.withLock { $0.macAddress = newValue } } + get { state.macAddress } + set { state.macAddress = newValue } } - struct State { - var address: String - var gateway: String - var macAddress: String? - #if !CURRENT_SDK - var reference: vmnet_network_ref - #endif + private struct State { + fileprivate var address: String + fileprivate var gateway: String + fileprivate var reference: vmnet_network_ref! + fileprivate var macAddress: String? } - #if !CURRENT_SDK - public var reference: vmnet_network_ref { - state.withLock { $0.reference } - } - #endif + @SendableProperty + private var state: State - private let state: Mutex - #if !CURRENT_SDK + @available(macOS 26, *) public init( address: String, gateway: String, @@ -66,29 +65,26 @@ public final class NATNetworkInterface: Interface, Sendable { macAddress: String? = nil ) { self.state = .init( - .init( - address: address, - gateway: gateway, - macAddress: macAddress, - reference: reference - ) + address: address, + gateway: gateway, + reference: reference, + macAddress: macAddress ) } - #else + + @available(macOS, obsoleted: 26, message: "Use init(address:gateway:reference:macAddress:) instead") public init( address: String, gateway: String, macAddress: String? = nil ) { self.state = .init( - .init( - address: address, - gateway: gateway, - macAddress: macAddress - ) + address: address, + gateway: gateway, + reference: nil, + macAddress: macAddress ) } - #endif } @available(macOS 26, *) @@ -102,11 +98,7 @@ extension NATNetworkInterface: VZInterface { config.macAddress = mac } - #if !CURRENT_SDK config.attachment = VZVmnetNetworkDeviceAttachment(network: self.reference) - #else - config.attachment = VZNATNetworkDeviceAttachment() - #endif return config } } diff --git a/scripts/make-docs.sh b/scripts/make-docs.sh index 08542587..406b896c 100755 --- a/scripts/make-docs.sh +++ b/scripts/make-docs.sh @@ -14,9 +14,6 @@ # limitations under the License. opts=() -if [ ! -z "${CURRENT_SDK}" ] ; then - opts+=("-Xswiftc" "-DCURRENT_SDK") -fi opts+=("--allow-writing-to-directory" "$1") opts+=("generate-documentation") opts+=("--target" "Containerization")