Introduction
So you have a binary that you wish to distribute but you are only able to compile for Windows and Linux at the moment. You have spent hours if not days googling for the appropriate way to cross-compile from Linux to Mac... Well, I am here to tell you I have been there and now provide an easy solution!
The Sauce
Basic Usage
# Setup Rust, use the x86_64-apple-darwin target but the rest can be customized.
- uses: ATiltedTree/setup-rust@v1
with:
targets: x86_64-apple-darwin
rust-version: nightly # Works both with 'stable' and 'nightly'
# Use the v1 of this action
- uses: mbround18/setup-osxcross@v1
# This builds executables & sets env variables for rust to consume.
with:
osx-version: "12.3"
# Checkout your code
- name: Clone your Code
uses: actions/checkout@v3
# Build your code for apple-darwin based release
- name: Build Your Code
run: cargo build --release --target x86_64-apple-darwin
Explanation of its Functionality
- It creates a folder called
osxcross
in the github actions working directory. (to avoid interference with any files you might be operating with) - Clones the
osxcross
repository - It downloads the SDK matching the version you specified from @joseluisq/macosx-sdks
- Checks cache
- Builds if cache wasn't hit
- Sets environment variables for build target
x86_64-apple-darwin
Top comments (0)