From d1402098fced522d5ba603d14912b5e984df9ff3 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sun, 18 Oct 2026 01:58:07 +0800 Subject: [PATCH] Add visionOS slices to the XCFramework Archive Compute for visionOS and the visionOS Simulator and include both in Compute.xcframework. Use canImport(Darwin) for the attribute vtable and type description branches in Swift. The C headers select these declarations with TARGET_OS_MAC, so visionOS must use the Darwin branch as well. --- Scripts/create-xcframework.sh | 16 ++++++++++++++++ Sources/Compute/Attribute/AttributeType.swift | 2 +- Sources/Compute/Runtime/Metadata.swift | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Scripts/create-xcframework.sh b/Scripts/create-xcframework.sh index 5d72cc45..258fb21f 100755 --- a/Scripts/create-xcframework.sh +++ b/Scripts/create-xcframework.sh @@ -25,12 +25,28 @@ xcodebuild archive \ -archivePath "$BUILD_DIR/Archives/Compute-iOS-Simulator.xcarchive" \ ENABLE_USER_SCRIPT_SANDBOXING=NO +xcodebuild archive \ + -project Xcode/Compute.xcodeproj \ + -scheme Compute \ + -destination "generic/platform=visionOS" \ + -archivePath "$BUILD_DIR/Archives/Compute-visionOS.xcarchive" \ + ENABLE_USER_SCRIPT_SANDBOXING=NO + +xcodebuild archive \ + -project Xcode/Compute.xcodeproj \ + -scheme Compute \ + -destination "generic/platform=visionOS Simulator" \ + -archivePath "$BUILD_DIR/Archives/Compute-visionOS-Simulator.xcarchive" \ + ENABLE_USER_SCRIPT_SANDBOXING=NO + rm -rf "$BUILD_DIR/Frameworks/Compute.xcframework" xcodebuild -create-xcframework \ -archive "$BUILD_DIR/Archives/Compute-macOS.xcarchive" -framework Compute.framework \ -archive "$BUILD_DIR/Archives/Compute-iOS.xcarchive" -framework Compute.framework \ -archive "$BUILD_DIR/Archives/Compute-iOS-Simulator.xcarchive" -framework Compute.framework \ + -archive "$BUILD_DIR/Archives/Compute-visionOS.xcarchive" -framework Compute.framework \ + -archive "$BUILD_DIR/Archives/Compute-visionOS-Simulator.xcarchive" -framework Compute.framework \ -output "$BUILD_DIR/Frameworks/Compute.xcframework" # Post-process swiftinterface files to replace ComputeCxx references with Compute diff --git a/Sources/Compute/Attribute/AttributeType.swift b/Sources/Compute/Attribute/AttributeType.swift index 36ce869d..c8542791 100644 --- a/Sources/Compute/Attribute/AttributeType.swift +++ b/Sources/Compute/Attribute/AttributeType.swift @@ -32,7 +32,7 @@ extension _AttributeType { vtable.pointee.self_destroy = { attributeType, body in attributeType.pointee.attributeBody._destroySelf(body) } - #if os(iOS) || os(macOS) + #if canImport(Darwin) vtable.pointee.self_description = { attributeType, body in let description: String if let selfType = attributeType.pointee.self_id.type diff --git a/Sources/Compute/Runtime/Metadata.swift b/Sources/Compute/Runtime/Metadata.swift index 76ff0af7..da651246 100644 --- a/Sources/Compute/Runtime/Metadata.swift +++ b/Sources/Compute/Runtime/Metadata.swift @@ -45,7 +45,7 @@ extension Metadata { extension Metadata: @retroactive CustomStringConvertible { public var description: String { - #if os(iOS) || os(macOS) + #if canImport(Darwin) return __IAGTypeDescription(self) as String #else return String(__IAGTypeCopyDescription(self))