From 238666dd0564d5e7c6ea2348eaa1c7413957bbbc Mon Sep 17 00:00:00 2001 From: James Moschou Date: Mon, 19 Jan 2026 10:45:17 +0100 Subject: [PATCH 1/5] Manually zip the xcframework bundle before uploading as a Github Actions artifact --- .github/workflows/swift.yml | 4 ++-- Scripts/create-xcframework.sh | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index baaf304..730b5bc 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -33,8 +33,8 @@ jobs: - name: Upload XCFramework uses: actions/upload-artifact@v6 with: - name: Compute.xcframework - path: .build/Xcode/Frameworks/Compute.xcframework + name: Compute.xcframework.zip + path: .build/Xcode/Frameworks/Compute.xcframework.zip linux-build: name: Linux diff --git a/Scripts/create-xcframework.sh b/Scripts/create-xcframework.sh index 1a65996..ad2001a 100755 --- a/Scripts/create-xcframework.sh +++ b/Scripts/create-xcframework.sh @@ -36,3 +36,8 @@ find "$BUILD_DIR/Frameworks/Compute.xcframework" -type d -name "Compute.framewor echo "Added Headers symlink to: $framework_dir" fi done + +# Zip the framework, preserving symlinks +cd "$BUILD_DIR/Frameworks" +zip -r -y Compute.xcframework.zip Compute.xcframework +echo "Created Compute.xcframework.zip" From 874149d112619fbbe166a8c50a31ff10db32afcf Mon Sep 17 00:00:00 2001 From: James Moschou Date: Mon, 19 Jan 2026 11:06:10 +0100 Subject: [PATCH 2/5] Support iOS and iOS Simulator when creating XCFramework bundle --- Scripts/create-xcframework.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Scripts/create-xcframework.sh b/Scripts/create-xcframework.sh index ad2001a..95e1d71 100755 --- a/Scripts/create-xcframework.sh +++ b/Scripts/create-xcframework.sh @@ -11,10 +11,26 @@ xcodebuild archive \ -archivePath "$BUILD_DIR/Archives/Compute-macOS.xcarchive" \ ENABLE_USER_SCRIPT_SANDBOXING=NO +xcodebuild archive \ + -project Compute.xcodeproj \ + -scheme Compute \ + -destination "generic/platform=iOS" \ + -archivePath "$BUILD_DIR/Archives/Compute-iOS.xcarchive" \ + ENABLE_USER_SCRIPT_SANDBOXING=NO + +xcodebuild archive \ + -project Compute.xcodeproj \ + -scheme Compute \ + -destination "generic/platform=iOS Simulator" \ + -archivePath "$BUILD_DIR/Archives/Compute-iOS-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 \ -output "$BUILD_DIR/Frameworks/Compute.xcframework" # Post-process swiftinterface files to replace ComputeCxx references with Compute From 65bfea2e103fc19646ce404634869da26c8860ec Mon Sep 17 00:00:00 2001 From: James Moschou Date: Mon, 19 Jan 2026 11:07:09 +0100 Subject: [PATCH 3/5] Move Swift checkout to .build/checkouts/swift and add clone-swift.sh script --- .github/workflows/swift.yml | 4 +- .gitignore | 3 -- Compute.xcodeproj/project.pbxproj | 12 +++--- Package.swift | 2 +- README.md | 29 +++----------- Scripts/clone-swift.sh | 65 +++++++++++++++++++++++++++++++ 6 files changed, 80 insertions(+), 35 deletions(-) create mode 100755 Scripts/clone-swift.sh diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 730b5bc..f0df066 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/checkout-swift-headers with: - path: Checkouts/swift + path: .build/checkouts/swift swift-version-major: ${{ steps.swift-version.outputs.major }} swift-version-minor: ${{ steps.swift-version.outputs.minor }} - name: Build @@ -59,7 +59,7 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/checkout-swift-headers with: - path: Checkouts/swift + path: .build/checkouts/swift swift-version-major: ${{ steps.swift-version.outputs.major }} swift-version-minor: ${{ steps.swift-version.outputs.minor }} - name: Build diff --git a/.gitignore b/.gitignore index 1539e6a..f4f7972 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,3 @@ # Xcode xcuserdata - -# Dependencies -Checkouts \ No newline at end of file diff --git a/Compute.xcodeproj/project.pbxproj b/Compute.xcodeproj/project.pbxproj index 46aec50..5ce996a 100644 --- a/Compute.xcodeproj/project.pbxproj +++ b/Compute.xcodeproj/project.pbxproj @@ -327,9 +327,9 @@ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; SWIFT_VERSION = 6.0; SYSTEM_HEADER_SEARCH_PATHS = ( - Checkouts/swift/include, - Checkouts/swift/stdlib/include, - Checkouts/swift/stdlib/public/SwiftShims, + .build/checkouts/swift/include, + .build/checkouts/swift/stdlib/include, + .build/checkouts/swift/stdlib/public/SwiftShims, ); TARGETED_DEVICE_FAMILY = "1,2,7"; USER_HEADER_SEARCH_PATHS = ( @@ -437,9 +437,9 @@ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; SWIFT_VERSION = 6.0; SYSTEM_HEADER_SEARCH_PATHS = ( - Checkouts/swift/include, - Checkouts/swift/stdlib/include, - Checkouts/swift/stdlib/public/SwiftShims, + .build/checkouts/swift/include, + .build/checkouts/swift/stdlib/include, + .build/checkouts/swift/stdlib/public/SwiftShims, ); TARGETED_DEVICE_FAMILY = "1,2,7"; USER_HEADER_SEARCH_PATHS = ( diff --git a/Package.swift b/Package.swift index f868e58..879b32d 100644 --- a/Package.swift +++ b/Package.swift @@ -2,7 +2,7 @@ import PackageDescription -let swiftCheckoutPath = "\(Context.packageDirectory)/Checkouts/swift" +let swiftCheckoutPath = "\(Context.packageDirectory)/.build/checkouts/swift" var dependencies: [Package.Dependency] = [ .package(url: "https://github.com/apple/swift-algorithms", from: "1.2.0"), diff --git a/README.md b/README.md index 56071dc..e437083 100644 --- a/README.md +++ b/README.md @@ -10,31 +10,14 @@ platforms. ### Project setup This project has a dependency on the Swift language codebase, which must be -configured manually. +cloned separately: -1. Clone the `swiftlang/swift` repository to `Checkouts/swift`. - - From within the package directory: - - ```sh - mkdir -p Checkouts - cd Checkouts - git clone git@github.com:swiftlang/swift.git swift - ``` - -2. Write the `CMakeConfig.h` file: - - From within the Swift repository: +```sh +./Scripts/clone-swift.sh +``` - ```sh - cat > include/swift/Runtime/CMakeConfig.h << EOF - #ifndef SWIFT_RUNTIME_CMAKECONFIG_H - #define SWIFT_RUNTIME_CMAKECONFIG_H - #define SWIFT_VERSION_MAJOR "6" - #define SWIFT_VERSION_MINOR "2" - #endif - EOF - ``` +This script will clone the Swift language repository to +`.build/checkouts/swift`. ### Build as a Swift package diff --git a/Scripts/clone-swift.sh b/Scripts/clone-swift.sh new file mode 100755 index 0000000..a7a4b9b --- /dev/null +++ b/Scripts/clone-swift.sh @@ -0,0 +1,65 @@ +#!/bin/zsh + +set -e + +# Default values +CHECKOUT_PATH=".build/checkouts/swift" +SWIFT_VERSION="" + +# Parse arguments +while [[ $# -gt 0 ]]; do + case $1 in + --path) + CHECKOUT_PATH="$2" + shift 2 + ;; + --swift-version) + SWIFT_VERSION="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" + echo "Usage: $0 [--path ] [--swift-version ]" + exit 1 + ;; + esac +done + +# Detect Swift version if not provided +if [ -z "$SWIFT_VERSION" ]; then + SWIFT_VERSION=$(swift --version 2>/dev/null | grep -oE 'Swift version [0-9]+\.[0-9]+' | grep -oE '[0-9]+\.[0-9]+') + echo "Detected Swift version: $SWIFT_VERSION" +fi + +SWIFT_VERSION_MAJOR=$(echo "$SWIFT_VERSION" | cut -d. -f1) +SWIFT_VERSION_MINOR=$(echo "$SWIFT_VERSION" | cut -d. -f2) + +# Remove existing checkout if present +rm -rf "$CHECKOUT_PATH" +mkdir -p "$CHECKOUT_PATH" + +# Clone with sparse checkout +git clone --filter=blob:none --no-checkout --depth 1 \ + --branch "release/$SWIFT_VERSION_MAJOR.$SWIFT_VERSION_MINOR" \ + git@github.com:swiftlang/swift.git "$CHECKOUT_PATH" + +cd "$CHECKOUT_PATH" + +git sparse-checkout set --no-cone \ + include/swift \ + stdlib/include \ + stdlib/public/SwiftShims \ + stdlib/public/runtime/MetadataAllocatorTags.def + +git checkout + +# Write CMakeConfig.h file +cat > include/swift/Runtime/CMakeConfig.h << EOF +#ifndef SWIFT_RUNTIME_CMAKECONFIG_H +#define SWIFT_RUNTIME_CMAKECONFIG_H +#define SWIFT_VERSION_MAJOR "$SWIFT_VERSION_MAJOR" +#define SWIFT_VERSION_MINOR "$SWIFT_VERSION_MINOR" +#endif +EOF + +echo "The Swift repository has been cloned to $CHECKOUT_PATH" From 42c7d4074837960a3185346c4da9ac729d7c8631 Mon Sep 17 00:00:00 2001 From: James Moschou Date: Mon, 19 Jan 2026 11:13:42 +0100 Subject: [PATCH 4/5] Lower deployment target to 26.0 from 26.2 in Xcode project file --- Compute.xcodeproj/project.pbxproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Compute.xcodeproj/project.pbxproj b/Compute.xcodeproj/project.pbxproj index 5ce996a..adf3bbc 100644 --- a/Compute.xcodeproj/project.pbxproj +++ b/Compute.xcodeproj/project.pbxproj @@ -293,7 +293,7 @@ ); INFOPLIST_KEY_NSHumanReadableCopyright = ""; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 26.2; + IPHONEOS_DEPLOYMENT_TARGET = 26.0; LD_RUNPATH_SEARCH_PATHS = ( "@executable_path/Frameworks", "@loader_path/Frameworks", @@ -303,7 +303,7 @@ "@loader_path/Frameworks", ); LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 26.2; + MACOSX_DEPLOYMENT_TARGET = 26.0; MARKETING_VERSION = 1.0; MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; @@ -339,7 +339,7 @@ USE_HEADERMAP = NO; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; - XROS_DEPLOYMENT_TARGET = 26.2; + XROS_DEPLOYMENT_TARGET = 26.0; }; name = Debug; }; @@ -405,7 +405,7 @@ ); INFOPLIST_KEY_NSHumanReadableCopyright = ""; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 26.2; + IPHONEOS_DEPLOYMENT_TARGET = 26.0; LD_RUNPATH_SEARCH_PATHS = ( "@executable_path/Frameworks", "@loader_path/Frameworks", @@ -415,7 +415,7 @@ "@loader_path/Frameworks", ); LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 26.2; + MACOSX_DEPLOYMENT_TARGET = 26.0; MARKETING_VERSION = 1.0; MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; @@ -449,7 +449,7 @@ USE_HEADERMAP = NO; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; - XROS_DEPLOYMENT_TARGET = 26.2; + XROS_DEPLOYMENT_TARGET = 26.0; }; name = Release; }; From 1f7187d225d77b03718a27951c2875ed37be5034 Mon Sep 17 00:00:00 2001 From: James Moschou Date: Mon, 19 Jan 2026 11:24:19 +0100 Subject: [PATCH 5/5] Update Swift compiler directives for iOS --- Sources/Compute/Attribute/AttributeType.swift | 2 +- Sources/Compute/Runtime/Metadata.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Compute/Attribute/AttributeType.swift b/Sources/Compute/Attribute/AttributeType.swift index 580589a..96acf19 100644 --- a/Sources/Compute/Attribute/AttributeType.swift +++ b/Sources/Compute/Attribute/AttributeType.swift @@ -51,7 +51,7 @@ extension _AttributeType { vtable.pointee.self_destroy = { attributeType, body in attributeType.pointee.attributeBody._destroySelf(body) } - #if os(macOS) + #if os(iOS) || os(macOS) 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 36021e1..be7a803 100644 --- a/Sources/Compute/Runtime/Metadata.swift +++ b/Sources/Compute/Runtime/Metadata.swift @@ -47,7 +47,7 @@ extension Metadata { extension Metadata: @retroactive CustomStringConvertible { public var description: String { - #if os(macOS) + #if os(iOS) || os(macOS) return __AGTypeDescription(self) as String #else return String(__AGTypeCopyDescription(self))