The developer docs may need a minor update addressing development on the newer Macs (M-series chips). Here is a sufficient-for-development build from source on arm64 MacOS without requiring niche workarounds for specific libraries. The following steps explain how to build Slicer from source on M-chip computers. Note that the Slicer build still targets x86_64 (i.e. run through Rosetta 2), but native arm64 builds may be rolled out at a future date. To summarize the steps:
Install Qt5 with x86_64 brew
Use x86_64 bash to build Slicer
Turn off SimpleITK
There were a few libraries which could not compile using later versions of clang. This discussion post is coupled with PR#8097, which cherry picks a few patches in files within libarchive.
Launch /bin/bash with Rosetta 2. x86_64 Homebrew is in /usr/local/bin/brew, and it installs binaries in /usr/local/bin. /usr/local/bin is added to PATH by default on MacOS, so all binaries are accessible without any custom profiles (e.g. .bash_profile, .bashrc). You should remain in the x86_64 /bin/bash for the rest of the build.
Be aware: On MacOS, /etc/paths configures your PATH such that binaries installed by Homebrew will be preferred over those in /bin. For example, if you install an x86_64 bash with /usr/local/bin/brew install bash, Homebrew-installed x86_64 /usr/local/bin/bash will be resolved when typing bash, not/bin/bash. For native arm64 Homebrew, be careful to set PATH=/opt/homebrew/bin:$PATH in custom profiles, or x86_64 binaries will always be resolved first, including brew.
Configure and build Slicer (from x86_64 /bin/bash). Note that arm64 cmake here is permissible:
Not all the tests pass, but you should be able to launch Slicer with ./Slicer-Debug/Slicer-build/Slicer. This should make it easier to develop and iterate over 3DSlicer on Apple Silicon devices. Thank you to @Jared_Vicory for helpful input and @jcfr for the invaluable support.
It appears that this build guide no longer works with the latest Xcode SDKs.
Instead, a downgrade is required due to the latest macOS SDK versions deprecating or excluding fp.h, among other things, in newer releases. Build issues were seen when installing VTK dependencies. I did not try bumping the VTK version used by Slicer or see whether later versions of VTK bump the VTK dependencies to versions that might fix build issues.
I have found that for Slicer v5.8.1 (11eaf62), downgrading the macOS SDK to 15.1, which is released with Xcode 16.1, I was able to build Slicer. To do this:
Extract Xcode_16.1.xip and move it to /Applications.
Note: This extracts to /Downloads/Xcode.app, but you should rename it to Xcode_16.1.app, as you will likely have multiple installations of Xcode on your system.
Follow all steps from the guide above, except replace the configuration step with the following:
@arhowe00 I think this very well may fix the build issues. See for example the following thread with Xcode 16.3 where a specific build fix was included in VTK 9.4. Slicer 5.8.1 was based on a VTK 9.2 version while latest Slicer Preview is based on VTK 9.4, so I would definitely try building latest Slicer Preview with a newer Xcode.
@arhowe00 You may also find helpful the instructions I added to the qt-easy-build project regarding building Slicer (x86_64) on Apple Silicon. I successfully built Qt 5.15.16 from source on an Apple silicon machine using the macOS 15.2 SDK. Building Qt from source allowed me to build a macOS package for distribution.
With this branch I added patches for clang 16 compatibility, but I haven’t checked the status of things if using clang 17 which was released in Xcode 16.3. It is unclear why Apple bumped clang in a minor release of Xcode this time around.
The fix in this reply is only needed if trying to build Slicer v5.8.1. If you need to build Slicer v5.8.1 or older and are having trouble using the macOS SDKs >15.2, Xcode >16.3, see the comment above.