fix: make desktop and iOS builds work without manual cargo config changes#443
fix: make desktop and iOS builds work without manual cargo config changes#443AnthonyRonning wants to merge 1 commit intomasterfrom
Conversation
…nges 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>
📝 WalkthroughWalkthroughThe PR consolidates build configuration by moving ORT_LIB_LOCATION from Cargo config to justfile environment setup for iOS, removing the desktop-build-no-cc command from documentation, and streamlining desktop build commands to properly unset Android NDK environment variables. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
Deploying maple with
|
| Latest commit: |
175fc57
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e8882df0.maple-ca8.pages.dev |
| Branch Preview URL: | https://fix-desktop-build-ort-compat.maple-ca8.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@justfile`:
- Around line 27-37: The simulator recipes ios-dev and ios-dev-sim are pointing
to the device slice "ios-arm64"; update the ORT_LIB_LOCATION used by simulator
targets to reference the simulator slice "ios-arm64-simulator" instead of
"ios-arm64" (leave the device recipe ios-dev-device unchanged); locate the
ORT_LIB_LOCATION assignments in the ios-dev and ios-dev-sim target definitions
and replace the path segment "onnxruntime.xcframework/ios-arm64" with
"onnxruntime.xcframework/ios-arm64-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}}' | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
ort-sys iOS ORT_LIB_LOCATION simulator ios-arm64 ios-arm64-simulator
💡 Result:
This looks like the Rust ort/ort-sys build script can’t find an ONNX Runtime static library slice that matches the iOS simulator ARM64 target.
What ORT_LIB_LOCATION must point to (for ort-sys)
ORT_LIB_LOCATION must be a directory that contains the compiled static ONNX Runtime libs (e.g. libonnxruntime.a, and the other libonnxruntime_* / libonnx.a libs), optionally inside a Release/Debug/... subfolder; ort-sys searches those patterns when linking. (ort.pyke.io)
The important target naming (Rust)
For Apple Silicon simulator you typically want:
- device:
aarch64-apple-ios - simulator (ARM64):
aarch64-apple-ios-sim(doc.rust-lang.org)
Why you’re hitting ios-arm64-simulator
Many ONNX Runtime builds/packages only provide:
- iOS device:
arm64 - iOS simulator: x86_64 (Intel simulator)
The ONNX Runtime iOS build docs still describe simulator as x86_64. (onnxruntime.ai)
So if your ORT build output only includes x86_64-simulator libs, linking will fail when Cargo is building aarch64-apple-ios-sim (Xcode slice name often shows up as ios-arm64-simulator / ios-arm64_x86_64-simulator).
Fix options
-
Build ONNX Runtime with an ARM64-simulator slice and set
ORT_LIB_LOCATIONto the folder containing the resulting.afiles for that slice.
(If you build an Apple XCFramework, make sure it actually contains an arm64-simulator library slice; arm64 iPhone simulator support is possible in ORT’s iOS packaging. (newreleases.io)) -
Instead build/run the simulator as x86_64 (Rosetta) and compile your Rust target as
x86_64-apple-iosso it matches the simulator libs that ORT’s docs/build commonly produce. (onnxruntime.ai)
If you paste the exact ort-sys error text (the “could not find native static library …” line) and what files are inside your ORT_LIB_LOCATION directory, I can tell you which specific library/slice it’s missing and what directory layout ort-sys is expecting.
Citations:
- 1: https://ort.pyke.io/setup/linking?utm_source=openai
- 2: https://doc.rust-lang.org/beta/rustc/platform-support/apple-ios.html?utm_source=openai
- 3: https://onnxruntime.ai/docs/build/ios.html?utm_source=openai
- 4: https://newreleases.io/project/pypi/onnxruntime/release/1.9.0?utm_source=openai
- 5: https://onnxruntime.ai/docs/build/ios.html?utm_source=openai
🏁 Script executed:
# Search for ORT_LIB_LOCATION usage in codebase
rg "ORT_LIB_LOCATION" -A 3 -B 3
# Search for ort-sys or ort configuration related to iOS
rg "ort-sys|ort_sys" --type toml -A 3
rg "ios" --type toml | head -20
# Check for any build or simulator configuration
fd "Cargo.toml" | xargs grep -l "ort\|onnx"Repository: OpenSecretCloud/Maple
Length of output: 2597
🏁 Script executed:
# Look for tauri iOS configuration
find . -name "*.json" -o -name "*.toml" | xargs grep -l "ios\|simulator" 2>/dev/null | head -20Repository: OpenSecretCloud/Maple
Length of output: 226
🏁 Script executed:
# Check the build script for iOS ONNX Runtime to see what slices are actually created
cat -n frontend/src-tauri/scripts/build-ios-onnxruntime.sh | head -100Repository: OpenSecretCloud/Maple
Length of output: 4024
🏁 Script executed:
# Look for tauri iOS configuration to understand what --simulator or lack thereof means
find . -path ./node_modules -prune -o -name "tauri.conf.json" -type f -print | xargs cat 2>/dev/null | grep -A 10 -B 10 "ios\|simulator" | head -50Repository: OpenSecretCloud/Maple
Length of output: 47
🏁 Script executed:
# Check if there's a .cargo/config.toml or similar that shows iOS build target configuration
cat -n frontend/src-tauri/.cargo/config.toml 2>/dev/null || echo "File not found, checking for generated config..."
fd "config.toml" frontend/src-tauri/ -exec cat -n {} \;Repository: OpenSecretCloud/Maple
Length of output: 361
🏁 Script executed:
# Check the build script more thoroughly to see what iOS targets it builds
sed -n '100,300p' frontend/src-tauri/scripts/build-ios-onnxruntime.shRepository: OpenSecretCloud/Maple
Length of output: 6579
🏁 Script executed:
# Look for the actual xcframework structure or any documentation about what slices it contains
find . -path ./node_modules -prune -o -name "*.xcframework" -type d -print
find . -path ./node_modules -prune -o -path "*/onnxruntime-ios/*" -type f -print 2>/dev/null | head -20Repository: OpenSecretCloud/Maple
Length of output: 47
🏁 Script executed:
# Check if there's any documentation or README about iOS builds in the scripts directory
ls -la frontend/src-tauri/scripts/ | grep -i ios
cat frontend/src-tauri/scripts/README.md 2>/dev/null || echo "No README found"Repository: OpenSecretCloud/Maple
Length of output: 307
🏁 Script executed:
# Search for references to ios-arm64-simulator or arm64-simulator in the codebase
rg "ios-arm64-simulator|arm64.*simulator|aarch64-apple-ios-sim" --type-listRepository: OpenSecretCloud/Maple
Length of output: 454
🏁 Script executed:
# Search for references to tauri ios dev to understand how it handles simulator targets
rg "tauri ios dev" -B 5 -A 5
# Check if there's a build-all script that might build the simulator
cat -n frontend/src-tauri/scripts/build-ios-onnxruntime-all.sh | head -150Repository: OpenSecretCloud/Maple
Length of output: 7367
🏁 Script executed:
# Look for any CI configuration that might build or use the simulator variant
fd "workflow\|action\|yml\|yaml" | xargs grep -l "ios\|simulator" 2>/dev/null | head -10Repository: OpenSecretCloud/Maple
Length of output: 47
Use ios-arm64-simulator slice for simulator development recipes.
ios-dev and ios-dev-sim currently point to ios-arm64 (the device slice). The xcframework includes a separate ios-arm64-simulator slice built specifically for simulator targets (via build-ios-onnxruntime-all.sh). Update both simulator recipes to use the correct slice:
Required change
ios-dev:
- cd frontend && ORT_LIB_LOCATION="$(pwd)/src-tauri/onnxruntime-ios/onnxruntime.xcframework/ios-arm64" bun run tauri ios dev
+ cd frontend && ORT_LIB_LOCATION="$(pwd)/src-tauri/onnxruntime-ios/onnxruntime.xcframework/ios-arm64-simulator" bun run tauri ios dev
ios-dev-sim simulator:
- cd frontend && ORT_LIB_LOCATION="$(pwd)/src-tauri/onnxruntime-ios/onnxruntime.xcframework/ios-arm64" bun run tauri ios dev '{{simulator}}'
+ cd frontend && ORT_LIB_LOCATION="$(pwd)/src-tauri/onnxruntime-ios/onnxruntime.xcframework/ios-arm64-simulator" bun run tauri ios dev '{{simulator}}'🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@justfile` around lines 27 - 37, The simulator recipes ios-dev and ios-dev-sim
are pointing to the device slice "ios-arm64"; update the ORT_LIB_LOCATION used
by simulator targets to reference the simulator slice "ios-arm64-simulator"
instead of "ios-arm64" (leave the device recipe ios-dev-device unchanged);
locate the ORT_LIB_LOCATION assignments in the ios-dev and ios-dev-sim target
definitions and replace the path segment "onnxruntime.xcframework/ios-arm64"
with "onnxruntime.xcframework/ios-arm64-simulator".
Problem
The
setup-ios-cargo-config.shscript generates a.cargo/config.tomlwith a global[env]section settingORT_LIB_LOCATIONto the iOS xcframework path. Since Cargo's[env]applies to all targets, this causesort-systo link iOS-compiled objects when building for macOS, breaking desktop builds.Additionally, the
desktop-buildanddesktop-build-no-cccommands only unsetCC, but the Android NDK also setsARandRANLIBwhich cause similar issues.Fix
[env]section from the generated.cargo/config.toml(the target-specific[target.aarch64-apple-ios.*]sections remain)ORT_LIB_LOCATIONas an env var in the justfile iOS commands (matching how CI already does it)desktop-buildnow always unsetsCC,AR,RANLIB(removes the separate-no-ccvariants)After merging
Run
just ios-setup-cargo-configto regenerate your local.cargo/config.tomlwithout the problematic[env]section.Summary by CodeRabbit