From 056b47fcd02379b65ce20299a210b769ad729dbb Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 14 Oct 2025 19:59:25 -0700 Subject: [PATCH] fix: ios hotpatching due to missing isysroot flag --- packages/cli/src/build/request.rs | 32 +++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/build/request.rs b/packages/cli/src/build/request.rs index 5ff7514d8..09fb4967e 100644 --- a/packages/cli/src/build/request.rs +++ b/packages/cli/src/build/request.rs @@ -868,6 +868,26 @@ impl BuildRequest { ]); } + // Make sure we set the sysroot for ios builds in the event the user doesn't have it set + if matches!(bundle, BundleFormat::Ios) { + let xcode_path = Workspace::get_xcode_path() + .await + .unwrap_or_else(|| "/Applications/Xcode.app".to_string().into()); + + let sysroot_location = match triple.environment { + target_lexicon::Environment::Sim => xcode_path + .join("Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"), + _ => xcode_path.join("Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"), + }; + + if sysroot_location.exists() && !rustflags.flags.iter().any(|f| f == "-isysroot") { + rustflags.flags.extend([ + "-Clink-arg=-isysroot".to_string(), + format!("-Clink-arg={}", sysroot_location.display()), + ]); + } + } + // automatically set the getrandom backend for web builds if the user requested it if matches!(bundle, BundleFormat::Web) && args.wasm_js_cfg { rustflags.flags.extend( @@ -1842,12 +1862,20 @@ impl BuildRequest { // -lxyz // There might be more, but some flags might break our setup. for (idx, arg) in original_args.iter().enumerate() { - if *arg == "-framework" || *arg == "-arch" || *arg == "-L" { + if *arg == "-framework" + || *arg == "-arch" + || *arg == "-L" + || *arg == "-target" + || *arg == "-isysroot" + { out_args.push(arg.to_string()); out_args.push(original_args[idx + 1].to_string()); } - if arg.starts_with("-l") || arg.starts_with("-m") { + if arg.starts_with("-l") + || arg.starts_with("-m") + || arg.starts_with("-nodefaultlibs") + { out_args.push(arg.to_string()); } }