From 175fc57b13945fa92fe18b6ba849ba4d56157e60 Mon Sep 17 00:00:00 2001 From: Tony Giorgio <101225832+TonyGiorgio@users.noreply.github.com> Date: Wed, 25 Feb 2026 18:30:41 -0600 Subject: [PATCH] fix: make desktop and iOS builds work without manual cargo config changes Remove the global [env] ORT_LIB_LOCATION from .cargo/config.toml generation since Cargo's [env] applies to all targets, causing ort-sys to link iOS objects when building for macOS. Instead, pass ORT_LIB_LOCATION as an env var in the justfile iOS commands (matching how CI already does it). Also consolidate desktop-build commands to always unset CC/AR/RANLIB (Android NDK env vars) since there's no reason to have separate -no-cc variants. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- CLAUDE.md | 3 +-- .../scripts/setup-ios-cargo-config.sh | 8 ++++--- justfile | 22 ++++++------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index ce11e227..7732d46c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -47,8 +47,7 @@ Use justfile for all commands (`just --list` to see all): - `just ios-dev-sim "iPhone 16 Pro"` - iOS specific simulator - `just ios-dev-device "Your iPhone"` - iOS physical device - `just android-build` - Android release build -- `just desktop-build` - Desktop release build -- `just desktop-build-no-cc` - Desktop build (with CC unset for compatibility) +- `just desktop-build` - Desktop release build (unsets Android NDK env vars) ### Rust (src-tauri) - `just rust-fmt` - Format Rust code diff --git a/frontend/src-tauri/scripts/setup-ios-cargo-config.sh b/frontend/src-tauri/scripts/setup-ios-cargo-config.sh index 8ec821ff..817a9967 100755 --- a/frontend/src-tauri/scripts/setup-ios-cargo-config.sh +++ b/frontend/src-tauri/scripts/setup-ios-cargo-config.sh @@ -31,6 +31,11 @@ cat > "$CONFIG_FILE" << EOF # Auto-generated cargo config for iOS ONNX Runtime linking # Generated by: scripts/setup-ios-cargo-config.sh # Regenerate with: ./scripts/setup-ios-cargo-config.sh +# +# NOTE: ORT_LIB_LOCATION is NOT set here because Cargo's [env] section applies +# globally to all targets, which breaks desktop builds (ort-sys links iOS objects +# for macOS). Instead, ORT_LIB_LOCATION is passed as an env var in the justfile +# iOS commands and in CI workflows. [target.aarch64-apple-ios.onnxruntime] rustc-link-search = ["${XCFRAMEWORK_DIR}/ios-arm64"] @@ -39,9 +44,6 @@ rustc-link-lib = ["static=onnxruntime"] [target.aarch64-apple-ios-sim.onnxruntime] rustc-link-search = ["${XCFRAMEWORK_DIR}/ios-arm64-simulator"] rustc-link-lib = ["static=onnxruntime"] - -[env] -ORT_LIB_LOCATION = "${XCFRAMEWORK_DIR}/ios-arm64" EOF echo "Created: $CONFIG_FILE" diff --git a/justfile b/justfile index de9e4810..213b4b71 100644 --- a/justfile +++ b/justfile @@ -25,15 +25,15 @@ lint: # Run Tauri iOS development build (default simulator) ios-dev: - cd frontend && bun run tauri ios dev + cd frontend && ORT_LIB_LOCATION="$(pwd)/src-tauri/onnxruntime-ios/onnxruntime.xcframework/ios-arm64" bun run tauri ios dev # Run Tauri iOS development build on specific simulator (e.g., "iPhone 16 Pro iOS 26") ios-dev-sim simulator: - cd frontend && bun run tauri ios dev '{{simulator}}' + cd frontend && ORT_LIB_LOCATION="$(pwd)/src-tauri/onnxruntime-ios/onnxruntime.xcframework/ios-arm64" bun run tauri ios dev '{{simulator}}' # Run Tauri iOS development build on physical device (e.g., "Your iPhone") ios-dev-device device: - cd frontend && bun run tauri ios dev --device '{{device}}' + cd frontend && ORT_LIB_LOCATION="$(pwd)/src-tauri/onnxruntime-ios/onnxruntime.xcframework/ios-arm64" bun run tauri ios dev --device '{{device}}' # Build ONNX Runtime for iOS (device + simulator) - required for TTS ios-build-onnxruntime: @@ -59,21 +59,13 @@ ios-fix-arch: android-build: cd frontend && bun run tauri android build -# Build Tauri desktop release +# Build Tauri desktop release (unsets Android NDK env vars that break macOS builds) desktop-build: - cd frontend && bun tauri build + cd frontend && unset CC AR RANLIB && bun tauri build -# Build Tauri desktop debug +# Build Tauri desktop debug (unsets Android NDK env vars that break macOS builds) desktop-build-debug: - cd frontend && bun tauri build --debug - -# Build Tauri desktop release (with CC unset for compatibility) -desktop-build-no-cc: - cd frontend && unset CC && bun tauri build - -# Build Tauri desktop debug (with CC unset for compatibility) -desktop-build-debug-no-cc: - cd frontend && unset CC && bun tauri build --debug + cd frontend && unset CC AR RANLIB && bun tauri build --debug # Format Rust code rust-fmt: