Open
Description
opened on Dec 24, 2022
I tried this code:
// build.rs
println!("cargo:rustc-link-search=framework=../../Frameworks/MacOS/Banuba/bnb-0.37.1/iOS/");
println!("cargo:rustc-link-lib=framework=BNBEffectPlayerC");
Folder structure (with frameworks):
- Frameworks/MacOS/Banuba/bnb-0.37.1/iOS
- BNBEffectPlayerC.xcframework
- ios-arm64
- BNBEffectPlayerC.framework
- ios-arm64_x86_64-simulator
- BNBEffectPlayerC.framework
- Info.plist
Expected behavior
I expected for the program to successfully link with BNBEffectPlayerC
library and automatically select correct 'sub-framework' based on the build target. Something like this:
aarch64-apple-ios
=>ios-arm64
aarch64-apple-ios-sim
=>ios-arm64_x86_64-simulator
x86_64-apple-ios
=>ios-arm64_x86_64-simulator
Actual behavior
Instead, linking fails with following error:
cargo build --release --target aarch64-apple-ios
Compiling banuba v0.1.0 (/Users/oleksandr/banuba-rs)
error: linking with `cc` failed: exit status: 1
= note: "cc" "-Wl, {tons and tons of arguments}
= note: ld: framework not found BNBEffectPlayerC
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Workaround
Following workaround is ugly and to properly implement it we should parse Info.plist
to select correct framework but it will require much more effort:
// build.rs
let is_simulator = env::var("TARGET").unwrap() == "aarch64-apple-ios-sim" || target == "x86_64-apple-ios";
let framework_folder = match is_simulator {
true => "ios-arm64_x86_64-simulator",
false => "ios-arm64",
};
println!("cargo:rustc-link-search=framework=../../Frameworks/MacOS/Banuba/bnb-0.37.1/iOS/BNBEffectPlayerC.xcframework/{}", framework_folder);
println!("cargo:rustc-link-lib=framework=BNBEffectPlayerC");
Proposed solution
Maybe it whould be better to add one more linking variant, something like xcframework
?
// build.rs
println!("cargo:rustc-link-search=xcframework=../../Frameworks/MacOS/Banuba/bnb-0.37.1/iOS/");
println!("cargo:rustc-link-lib=xcframework=BNBEffectPlayerC");
Meta
rustc --version --verbose
:
rustc 1.66.0 (69f9c33d7 2022-12-12)
binary: rustc
commit-hash: 69f9c33d71c871fc16ac445211281c6e7a340943
commit-date: 2022-12-12
host: aarch64-apple-darwin
release: 1.66.0
LLVM version: 15.0.2
Activity