doc/macos.md
macOS Users need to follow some extra steps to get the radare2 program signed and ready to debug other applications without running it as root. Same happens for iOS users, read doc/ios for more information.
To compile for macOS automatically, do it this way:
$ sys/install.sh
When running radare2 on arm64e processors, it is necessary to build radare2 for this specific architecture, because it is required to work with the pointer authentication stuff. To do this you'll need to:
csrutil disable)Use this script snippet as inspiration to achieve it:
sudo nvram boot-args=-arm64e_preview_abi
sudo reboot
export CFLAGS="-arch arm64e"
sys/install.sh
If you want to use the debugger via ssh or the sdk was not properly setup you must run:
$ sudo DevToolsSecurity -enable
You cannot debug binaries located outside your home, if you want to do that you should disable SIP:
$ csrutil disable
After Mac OS X 10.6, binaries that need permissions to debug require to be signed and include a .plist describing them. The aforementioned install.sh script will install a new code signing certificate into the system keychain and sign r2 with it. Alternatively, you can manually create a code signing certificate by following the following steps:
(Based on https://llvm.org/svn/llvm-project/lldb/trunk/docs/code-signing.txt)
As said before, the signing process can also be done manually following the next process. First, you will need to sign the radare2 binary:
$ make -C binr/radare2 macossign
But this is not enough. As long as r2 code is split into several libraries, you should sign every single dependency (libr*).
$ make -C binr/radare2 macos-sign-libs
Another alternative is to build a static version of r2 and just sign it.
$ sys/static.sh
$ make -C binr/radare2 macossign
You can verify that the binary is properly signed and verified by using the code signing utility:
$ codesign -dv binr/radare2/radare2
Additionally, you can run the following command to add the non-privileged user (username) to the Developer Tools group in macOS, avoiding the related Xcode prompts:
$ sudo dscl . append /Groups/_developer GroupMembership <username>
After doing it you should be able to debug on macOS without root permissions!
$ r2 -d mybin
Note: if you already have a valid certificate for code signing, you can specify its name by setting the env var CERTID.
To create a macOS .pkg just run the following command:
$ sys/osx-pkg.sh
To uninstall the .pkg downloaded from the r2 website or the one you have generated with sys/osx-pkg.sh, run the following as root:
$ pkgutil --only-files --files org.radare.radare2 | sed 's/^/\//' | tr '\n' '\0' | xargs -o -n 1 -0 rm -i