iroh transport P2: cmux-iroh FFI packaging (crate + xcframework + CI toolchain)
Implements delivery-plan step 2 of https://github.com/manaflow-ai/cmux/blob/main/plans/feat-ios-iroh/DESIGN.md (iroh as the default iOS-to-Mac transport; decision 2026-06-09).
Graduates the FFI spike to native/cmux-iroh/ (iroh pinned =1.0.2, blocking C API: keygen, bind with caller-provided secret key, id, route JSON, online, accept, connect, recv, send, close; stable error-kind codes for CmxConnectFailureKind mapping; ALPN dev.cmux.mobile.terminal/0). Adds scripts/ensure-cmux-iroh.sh building CmuxIrohFFI.xcframework (macOS arm64+x86_64 universal, iOS device arm64, iOS sim arm64) mirroring the GhosttyKit ensure pattern, wires it into reload/setup/ios scripts, adds iOS Rust targets to scripts/install-rust-ci.sh, and provisions the toolchain across CI workflows. The xcframework links into both apps but is referenced by no code: zero behavior change.
Verified: cargo build on all 4 targets; cargo test echo self-test; xcframework slice check (macOS x86_64+arm64, iOS device arm64, sim arm64); macOS compile-only tagged build; iOS arm64-sim compile-only build; pbxproj + workspace-groups + Package.resolved lints.
Part of a stacked series: P3 phone dial lane and P4 Mac host lane follow on top of this branch.
🤖 Generated with Claude Code
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.
[!NOTE]
Medium Risk
Large new native dependency (iroh) and broad CI/build changes affect every macOS/iOS compile; the terminal resync change touches mobile replay lifecycle but is localized and tested.
Overview
Adds native/cmux-iroh (iroh =1.0.2) with a blocking C API for endpoint bind/connect, route JSON, and bidirectional streams, plus scripts/ensure-cmux-iroh.sh to build and cache CmuxIrohFFI.xcframework (macOS universal, iOS device/sim) like GhosttyKit. macOS and iOS Xcode projects link the xcframework and add SystemConfiguration / Security / Network (iOS) / CoreWLAN (macOS); the artifact is gitignored.
CI and local builds call ensure-cmux-iroh.sh after Rust install; install-rust-ci.sh gains iOS Rust targets; release drops inline rustup in favor of that script; setup/reload and iOS TestFlight scripts provision the FFI.
Mobile shell: introduces requestTerminalResync so sync resyncs defer when a replay barrier owns the surface (avoids racing stale replays); the iOS test is tightened around subscribe ordering and replay ordinals.
No Swift call sites into the FFI yet—link-only packaging for the iroh transport lane.
Reviewed by Cursor Bugbot for commit ff236970e0fb957fe3eaa41abb1d1d0e7085dcbb. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Packages the new native/cmux-iroh Rust FFI into CmuxIrohFFI.xcframework and wires it into scripts/CI for macOS and iOS builds. Adds a terminal replay ownership fix; the iroh framework is linked but unused, so transport behavior is unchanged.
-
New Features
- Added
native/cmux-irohcrate (iroh=1.0.2) with a blocking C API: keygen, bind, id/route JSON, online, accept/connect, recv/send, close; stable error codes; ALPNdev.cmux.mobile.terminal/0. - Built
CmuxIrohFFI.xcframework(macOS arm64+x86_64, iOS arm64 device, iOS arm64 sim) viascripts/ensure-cmux-iroh.shwith caching; linked into macOS and iOS Xcode projects. - Provisioned across CI/local flows:
scripts/setup.sh,scripts/reload.sh, reload-build, test (test-ios,test-e2e,test-depot), nightly, perf, macOS compat,ios-testflight,ios-app-store, and release (now usesscripts/install-rust-ci.sh); iOS lanes provision the FFI before Xcode resolves frameworks. Added Rust targets inscripts/install-rust-ci.sh(aarch64-apple-ios,aarch64-apple-ios-sim). - Linked system frameworks: macOS
SystemConfiguration,CoreWLAN,Security; iOSSystemConfiguration,Security,Network; ignoredCmuxIrohFFI.xcframeworkin git.
- Added
-
Bug Fixes
- Serialized terminal resync ownership to avoid racing an in-flight replay barrier; added
requestTerminalResyncand routed resyncs through it. - Made the terminal resync test deterministic by gating on initial subscribe and tracking replay ordinals with stream tokens.
- Serialized terminal resync ownership to avoid racing an in-flight replay barrier; added
Summary by CodeRabbit
-
New Features
- Added a native networking layer integration for iOS and macOS, including endpoint setup, connection send/receive, and structured error reporting.
- Improved terminal replay recovery by introducing a resync request for terminal output.
-
Build Improvements
- Automated provisioning and caching of the required native Apple binaries across CI workflows and local setup, including release builds.
- Expanded CI Rust target installation for iOS and simulators.
-
Bug Fixes
- Improved iOS/e2e terminal resync test reliability by removing race-prone behavior and making token handling deterministic.