* Initial changes * index fix * gz index fix2 * gz index fix 3 * updates * Run prettier * zsh env removed gz classic * Corrections 2 * Cleanups * Update docs/en/dev_setup/dev_env_mac.md * Apply suggestions from code review * Minor subedit and prettier * small correction * cleanups gz harmonic brew formula * fix(macos.sh): invert px4-sim install condition for --sim-tools The condition checked if px4-sim WAS installed before running brew install, meaning it would never install on a fresh system. Add the missing negation so it installs when NOT already present. Signed-off-by: Ramon Roche <mrpollo@gmail.com> * docs: rewrite macOS dev environment setup guide - Add Xcode Command Line Tools as prerequisite - Default to ~/.zshrc (macOS default since Catalina) - Explain why ulimit change is needed and why in startup file - Add reminder to open new terminal after shell config changes - Remove broken pip3 alias workaround - Split git clone into clone + submodule update (canonical form) - Recommend --sim-tools flag since first build uses gz_x500 - Document what macos.sh installs and its --reinstall flag - Clarify Gazebo comes from --sim-tools / px4-sim formula - Add XQuartz requirement for Gazebo display - Add verification section with key tool checks and smoke test - Remove outdated video guide comment block Signed-off-by: Ramon Roche <mrpollo@gmail.com> * conventions --------- Signed-off-by: Ramon Roche <mrpollo@gmail.com> Co-authored-by: Hamish Willee <hamishwillee@gmail.com> Co-authored-by: Ramon Roche <mrpollo@gmail.com>
4.1 KiB
macOS Development Environment
The following instructions set up a PX4 development environment on macOS. This environment can be used to build PX4 for:
- Pixhawk and other NuttX-based hardware
- Gazebo Simulation (Gazebo Harmonic)
It works on both Intel and Apple Silicon Macs.
:::tip This setup is supported by the PX4 dev team. To build for other targets you will need to use a different OS or an unsupported development environment. :::
Development Environment Setup
Prerequisites
-
Install Xcode Command Line Tools — provides
git,make, and the Appleclangcompiler:xcode-select --install -
Install Homebrew by following the installation instructions.
-
Increase the open-file limit. The PX4 build opens many files simultaneously and the macOS default limit (256) is too low — you may see
"LD: too many open files"errors without this.Add the following line to your shell startup file so it applies to every new terminal session. macOS defaults to zsh since Catalina, so add it to
~/.zshrc(use~/.bashrcif you use bash):echo "ulimit -S -n 2048" >> ~/.zshrcThen open a new terminal (or run
source ~/.zshrc) for the change to take effect. -
Ensure Python 3 is available. Some PX4 build scripts require
python3andpip3to be in yourPATH. The Xcode Command Line Tools include Python 3 by default.:::tip If you need to install or manage a different Python version, we recommend pyenv, which lets you set global and per-directory Python versions. :::
Install Development Tools
-
Download PX4 Source Code:
git clone https://github.com/PX4/PX4-Autopilot.git cd PX4-Autopilot git submodule update --init --recursive --force -
Install development environment libraries from the macos.sh helper script:
./Tools/setup/macos.sh --sim-toolsThis installs:
px4-dev— ARM cross-compiler (arm-gcc-bin@13),cmake,ninja,ccache, and other build tools- Python packages from
requirements.txt px4-sim(via--sim-tools) — Gazebo Harmonic simulation (gz-harmonic) and related tools
::: info Omit
--sim-toolsif you only need to build for NuttX hardware and don't need simulation.Use
--reinstallto force reinstallation of all Homebrew formulas (useful if something is broken). :::
Gazebo Simulation
The --sim-tools flag installs the px4-sim Homebrew formula, which pulls in Gazebo Harmonic.
If you skipped --sim-tools during initial setup and want to add simulation later:
brew tap PX4/px4
brew install px4-sim
::: info Gazebo requires XQuartz for display on macOS. If you don't already have it installed:
brew install --cask xquartz
You may need to log out and back in after installing XQuartz. :::
Verify Installation
After installation, verify the key tools are available:
# NuttX cross-compiler (from arm-gcc-bin@13)
arm-none-eabi-gcc --version
# Build tools
cmake --version
ninja --version
# Gazebo (if --sim-tools was used)
gz sim --versions
Quick smoke test — build and run a simulation target:
make px4_sitl gz_x500
If everything is set up correctly, this will build PX4 SITL and launch a Gazebo simulation with the x500 quadcopter.
Next Steps
Once you have finished setting up the command-line toolchain:
-
Install VSCode (if you prefer using an IDE to the command line).
-
Install the QGroundControl Daily Build
::: tip The daily build includes development tools that are hidden in release builds. It may also provide access to new PX4 features that are not yet supported in release builds. :::
-
Continue to the build instructions.