Skip to content

fix: make desktop and iOS builds work without manual cargo config changes#443

Open
AnthonyRonning wants to merge 1 commit intomasterfrom
fix/desktop-build-ort-compat
Open

fix: make desktop and iOS builds work without manual cargo config changes#443
AnthonyRonning wants to merge 1 commit intomasterfrom
fix/desktop-build-ort-compat

Conversation

@AnthonyRonning
Copy link
Contributor

@AnthonyRonning AnthonyRonning commented Feb 26, 2026

Problem

The setup-ios-cargo-config.sh script generates a .cargo/config.toml with a global [env] section setting ORT_LIB_LOCATION to the iOS xcframework path. Since Cargo's [env] applies to all targets, this causes ort-sys to link iOS-compiled objects when building for macOS, breaking desktop builds.

Additionally, the desktop-build and desktop-build-no-cc commands only unset CC, but the Android NDK also sets AR and RANLIB which cause similar issues.

Fix

  • Remove the [env] section from the generated .cargo/config.toml (the target-specific [target.aarch64-apple-ios.*] sections remain)
  • Pass ORT_LIB_LOCATION as an env var in the justfile iOS commands (matching how CI already does it)
  • Consolidate desktop build commands: desktop-build now always unsets CC, AR, RANLIB (removes the separate -no-cc variants)
  • Update CLAUDE.md to reflect the simplified commands

After merging

Run just ios-setup-cargo-config to regenerate your local .cargo/config.toml without the problematic [env] section.


Open with Devin

Summary by CodeRabbit

  • Chores
    • Improved macOS desktop build compatibility through refined environment variable management.
    • Streamlined iOS build setup with enhanced environment configuration handling.

…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>
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Documentation Update
CLAUDE.md
Removed desktop-build-no-cc command reference and annotated desktop-build to note Android NDK environment variable clearing behavior.
Build Configuration
frontend/src-tauri/scripts/setup-ios-cargo-config.sh, justfile
Moved ORT_LIB_LOCATION environment variable provisioning from Cargo config to justfile iOS dev commands; consolidated desktop build commands to unset Android NDK variables (CC, AR, RANLIB) before execution.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Build scripts dancing, consolidating with care,
Environment variables find their rightful lair,
Desktop clears the Android dust away,
iOS gets its libraries through justfile's way,
Config cleaned up—hopping to a brighter day! ✨

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing the need for manual cargo config modifications by automatically handling build environment variables for both desktop and iOS builds.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/desktop-build-ort-compat

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

Deploying maple with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d92094 and 175fc57.

📒 Files selected for processing (3)
  • CLAUDE.md
  • frontend/src-tauri/scripts/setup-ios-cargo-config.sh
  • justfile

Comment on lines 27 to 37
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}}'

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 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

  1. Build ONNX Runtime with an ARM64-simulator slice and set ORT_LIB_LOCATION to the folder containing the resulting .a files 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))

  2. Instead build/run the simulator as x86_64 (Rosetta) and compile your Rust target as x86_64-apple-ios so 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:


🏁 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 -20

Repository: 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 -100

Repository: 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 -50

Repository: 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.sh

Repository: 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 -20

Repository: 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-list

Repository: 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 -150

Repository: 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 -10

Repository: 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant