Nightly-x86_64-apple-darwin updated - (rustc does not exist) (from (rustc does not exist))

My main development machine is running Windows 10. I wanted to try some cross compilation to MacOS and therefore executed the following two comands to get the appropriate toolchain, or so I thought:

rustup toolchain install nightly-x86_64-apple-darwin
rustup target add nightly-x86_64-apple-darwin

When updating Rust I am getting this:

nightly-x86_64-apple-darwin updated - (rustc does not exist) (from (rustc does not exist))

And when I try to compile a sample project I am getting:

error: Error loading target specification: Could not find specification for target "nightly-x86_64-apple-darwin". Use `--print target-list` for a list of built-in targets

How can I install the correct tooling to compile targeting MacOS from Windows?

You don't need to install a separate toolchain. Instead, just add an additional target to your normal toolchain. (The apple-darwin toolchain is used when compiling on MacOS, while the target is used when compiling for MacOS.)

The name of the target does not include nightly. Here's the command to install it:

rustup target add x86_64-apple-darwin

And the command to run it is:

cargo build --target x86_64-apple-darwin
cargo run --target x86_64-apple-darwin

You will also need a MacOS linker, and you will need to configure Cargo for cross-linking. The osxcross project has a linker that works on Linux. Maybe it will also work in Windows 10 using WSL.

1 Like