Rustup macabi toolchain

I'm attempting to build the rfd(GitHub - PolyMeilex/rfd: Rusty File Dialog) package for Mac Catalyst. I'm running into a linking issue when building an example.

I've successfully compiled the library with the following:

cargo +nightly build -Z build-std --release --lib --target x86_64-apple-ios-macabi

When I try to compile the example with:

cargo +nightly build -Z build-std --release --example simple --target x86_64-apple-ios-macabi

I receive the following error:

= note: ld: warning: directory not found for option '-L~/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-ios-macabi/lib'
          ld: warning: directory not found for option '-L~/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-ios-macabi/lib'
          Undefined symbols for architecture x86_64:
            "_CGShieldingWindowLevel", referenced from:
                rfd::backend::macabi::file_dialog::panel_ffi::Panel::new::h50dc944e150e1ae9 in librfd-3591fabd0bc37163.rlib(rfd-3591fabd0bc37163.rfd.8464c089a5c38870-cgu.01.rcgu.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm not sure how the nightly toolchains interact with rustup, but the only toolchains visible in ~/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/ are


There was a previous topic on this from October of 2022, but it was locked without a resolution.

The solution was to add

"ios" => {

to the file so that the linker can find the appropriate framework for the missing reference CGShieldingWindowLevel.

The full file looks like this:

fn main() {
    let target_os = std::env::var("CARGO_CFG_TARGET_OS").expect("target OS not detected");

    match target_os.as_str() {
        "macos" => println!("cargo:rustc-link-lib=framework=AppKit"),
        "ios" => {
        "windows" => {}
        _ => {
            let gtk = std::env::var_os("CARGO_FEATURE_GTK3").is_some();
            let xdg = std::env::var_os("CARGO_FEATURE_XDG_PORTAL").is_some();

            if gtk && xdg {
                panic!("You can't enable both `gtk3` and `xdg-portal` features at once");
            } else if !gtk && !xdg {
                panic!("You need to choose at least one backend: `gtk3` or `xdg-portal` features");