From dce89341a970a6380a90c5c1f44dd96c8d14ccf3 Mon Sep 17 00:00:00 2001 From: Sean Olszewski Date: Wed, 13 May 2026 16:35:53 -0700 Subject: [PATCH 1/2] fix(examples): auto-build Swift bindings in Xcode pre-action Replace the validation-only pre-build script with one that automatically runs `scripts/package-swift.sh` when the xcframework or generated bindings are missing or when Rust sources are newer than the artifacts. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../xcschemes/IDKitSampleApp.xcscheme | 4 ++-- swift/Examples/IDKitSampleApp/project.yml | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/swift/Examples/IDKitSampleApp/IDKitSampleApp.xcodeproj/xcshareddata/xcschemes/IDKitSampleApp.xcscheme b/swift/Examples/IDKitSampleApp/IDKitSampleApp.xcodeproj/xcshareddata/xcschemes/IDKitSampleApp.xcscheme index 8be6f12b..b5fe4d0f 100644 --- a/swift/Examples/IDKitSampleApp/IDKitSampleApp.xcodeproj/xcshareddata/xcschemes/IDKitSampleApp.xcscheme +++ b/swift/Examples/IDKitSampleApp/IDKitSampleApp.xcodeproj/xcshareddata/xcschemes/IDKitSampleApp.xcscheme @@ -10,8 +10,8 @@ + title = "Build IDKit Dependencies" + scriptText = "REPO_ROOT="${SRCROOT}/../../.." XCFRAMEWORK="${REPO_ROOT}/IDKitFFI.xcframework" GENERATED="${REPO_ROOT}/swift/Sources/IDKit/Generated/idkit_core.swift" RUST_SRC="${REPO_ROOT}/rust/core/src" NEEDS_BUILD=0 if [ ! -d "${XCFRAMEWORK}" ] || [ ! -f "${GENERATED}" ]; then NEEDS_BUILD=1 elif [ -n "$(find "${RUST_SRC}" -newer "${GENERATED}" -name '*.rs' -print -quit)" ]; then NEEDS_BUILD=1 fi if [ "${NEEDS_BUILD}" -eq 1 ]; then echo "note: IDKit native artifacts missing or stale — rebuilding..." "${REPO_ROOT}/scripts/package-swift.sh" fi "> &2 - echo "error: Run the following from the repo root, then build again:" >&2 - echo "error: ./scripts/package-swift.sh" >&2 - exit 1 + NEEDS_BUILD=1 + elif [ -n "$(find "${RUST_SRC}" -newer "${GENERATED}" -name '*.rs' -print -quit)" ]; then + NEEDS_BUILD=1 + fi + + if [ "${NEEDS_BUILD}" -eq 1 ]; then + echo "note: IDKit native artifacts missing or stale — rebuilding..." + "${REPO_ROOT}/scripts/package-swift.sh" fi - name: Check IDKit Dependencies + name: Build IDKit Dependencies settingsTarget: IDKitSampleApp run: config: Debug From 787a89f066bb81fc29a5b35e24edfe021dd50499 Mon Sep 17 00:00:00 2001 From: Sean Olszewski Date: Thu, 14 May 2026 07:46:09 -0700 Subject: [PATCH 2/2] fix: ensure cargo is in PATH in package-swift.sh On some CI runners (e.g. macOS with Xcode 26.0.1), the rustup cargo proxy is not in PATH even after toolchain installation, causing `cargo` to resolve to `rustup-init`. Source the cargo environment when cargo is not found. Co-Authored-By: Claude Opus 4.6 (1M context) --- scripts/package-swift.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/package-swift.sh b/scripts/package-swift.sh index bd0ecaab..bc32efe8 100755 --- a/scripts/package-swift.sh +++ b/scripts/package-swift.sh @@ -3,6 +3,12 @@ set -euo pipefail SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )" + +# Ensure cargo is in PATH (rustup proxy may not be available on all CI runners) +if ! command -v cargo &>/dev/null; then + # shellcheck source=/dev/null + [ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" +fi SWIFT_DIR="$PROJECT_ROOT/swift" GENERATED_DIR="$SWIFT_DIR/Sources/IDKit/Generated" IOS_BUILD="$PROJECT_ROOT/ios_build"