Host Setup on macOS
Extract and verify the SPECS NDK on a macOS build host, install CMake, and enable Rosetta 2 on Apple silicon.
This page applies to macOS hosts; Windows users see Host Setup on Windows. macOS setup is short: the SPECS NDK runs in place wherever you extract it, so there is no relocation step.
Before you start on macOS
-
macOS (darwin21 or later).
-
Rosetta 2 on Apple silicon Macs. The SPECS NDK's macOS host tools (
clang,clang++,ninja,specs-perm-embed) are x86_64 binaries. Intel Macs run them directly; Apple silicon Macs run them through Rosetta 2. If Rosetta 2 isn't installed yet, install it once:softwareupdate --install-rosetta --agree-to-license -
CMake 3.24 or later. CMake is bundled in the Windows tarball but not in the macOS one, so install your own. Version 3.24 or later is needed for automatic permission embedding (see Permission Annotations and Manifest Embedding). With Homebrew:
brew install cmakecmake --version -
pkg-config, only if your CMake project uses
pkg_check_modules(see Linking and pkg-config):brew install pkg-config.
Extract the SPECS NDK on macOS
Get the macOS tarball, specsndk-armv8-1.3.0-darwin21-x86_64.tar, from the Downloads page. It is XZ-compressed despite the .tar name, so extract it with tar -xJf. The tarball's contents extract directly into the folder you give it, so create the install folder first:
mkdir -p ~/specsndk
tar -xJf specsndk-armv8-1.3.0-darwin21-x86_64.tar -C ~/specsndk
The install folder now holds the toolchain files (SpecsNDK-Toolchain-Clang.cmake, SpecsNDK-Toolchain-common.cmake, and SpecsNDK-Toolchain-Simulator-macOS.cmake for the macOS Simulator) and sysroots/. For the full layout, see Prerequisites and NDK Layout.
Why macOS needs no relocation step
macOS (Mach-O) binaries find their libraries through relative @rpath and @executable_path entries, so the SPECS NDK works from any folder you extract it to, and keeps working if you move it. The tarball also contains relocate_sdk.py and post-relocate-setup.sh; you don't need to run them on macOS.
Verify the SPECS NDK on macOS
Run the bundled compiler from the host-tools folder for macOS, sysroots/x86_64-specsndk-darwin21/:
~/specsndk/sysroots/x86_64-specsndk-darwin21/usr/bin/clang --version
The first line reads clang version 18.1.8. If it doesn't run on an Apple silicon Mac, check that Rosetta 2 is installed (see Before you start on macOS).
Then build the sample in Build your first Native Lens. With the SPECS NDK installed in ~/specsndk, pass -DCMAKE_TOOLCHAIN_FILE=~/specsndk/SpecsNDK-Toolchain-Clang.cmake when you configure.
Related
- Prerequisites and NDK Layout: host requirements and where each tool lives.
- Build your first Native Lens: configure, build, and check an aarch64 library.
- Troubleshooting: fixes for common build problems.