How to link AppKit framework in rustflags?

I installed and clang_16 with nix on my macOS.

I checked out the bevy repo then built it.

$ cd bevy
$ cargo build --example breakout -vvv
= note: ld: framework not found AppKit
            clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

cat ~/.cargo/config

linker = "clang"
rustflags = [
  "-C", "link-arg=-fuse-ld=mold",
  "-Z", "share-generics=y",
  "-Z", "threads=8",
  "-Z", "codegen-backend=cranelift",

How to fix that?

Usually you don't use rustflags for linking of anything.

Linking is done by sys crates. However, there is no crate for AppKit yet. So in that case you could use #[link] directive to make Rust link to it:

#[link(name = "AppKit", kind = "framework")]
extern "C" {}

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.