From 652cfde2f459c8a11d32d63176993d44465fd9f5 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 23 Oct 2026 12:16:44 -0400 Subject: [PATCH] fix(berd-call): link Swift bridges built by the swiftbuild system Newer Xcode defaults `swift build` to the swiftbuild system, which writes products to `/out/Products/`. swift-rs 1.0.7 only adds `/-apple-macosx/` to the link search path, so the BerdMacSpeechBridge and BerdAirPodsBridge static libraries were not found even though `swift build` succeeded. Also emit the new products directory as a link search path. The old layout keeps working because the extra path is simply unused there. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Henry --- src-tauri/build.rs | 12 ++++++++++++ src-tauri/crates/berd-call/build.rs | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src-tauri/build.rs b/src-tauri/build.rs index fbaa9e8c9..fd9c60598 100644 --- a/src-tauri/build.rs +++ b/src-tauri/build.rs @@ -14,6 +14,18 @@ fn main() { .with_package("BerdAirPodsBridge", "swift/BerdAirPodsBridge") .link(); + // swift-rs expects SwiftPM's `-apple-macosx/` layout, but the + // swiftbuild system in newer Xcode writes `out/Products/` instead. + let config = if std::env::var("DEBUG").as_deref() == Ok("true") { + "Debug" + } else { + "Release" + }; + println!( + "cargo:rustc-link-search=native={}/swift-rs/BerdAirPodsBridge/out/Products/{config}", + std::env::var("OUT_DIR").unwrap() + ); + // Swift packages linked into a Rust executable use @rpath for the // system Swift runtime, which is available from this stable path. println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/lib/swift"); diff --git a/src-tauri/crates/berd-call/build.rs b/src-tauri/crates/berd-call/build.rs index 16244a377..a255a24d2 100644 --- a/src-tauri/crates/berd-call/build.rs +++ b/src-tauri/crates/berd-call/build.rs @@ -11,6 +11,18 @@ fn main() { swift_rs::SwiftLinker::new("14.0") .with_package("BerdMacSpeechBridge", "swift/BerdMacSpeechBridge") .link(); + + // swift-rs expects SwiftPM's `-apple-macosx/` layout, but the + // swiftbuild system in newer Xcode writes `out/Products/` instead. + let config = if std::env::var("DEBUG").as_deref() == Ok("true") { + "Debug" + } else { + "Release" + }; + println!( + "cargo:rustc-link-search=native={}/swift-rs/BerdMacSpeechBridge/out/Products/{config}", + std::env::var("OUT_DIR").unwrap() + ); for framework in ["Foundation", "AVFoundation", "AudioToolbox", "CoreAudio"] { println!("cargo:rustc-link-lib=framework={framework}"); }