|
| 1 | +# Antivirus Software |
| 2 | + |
| 3 | +Many operating systems include antivirus software programs that scan the system for malware. These sometimes interfere with development workflows, see below. |
| 4 | + |
| 5 | +## XProtect |
| 6 | + |
| 7 | +macOS has a layered system for protecting against malware, see [Apple's documentation](https://support.apple.com/en-gb/guide/security/sec469d47bd8/web) for details. One of the components here is XProtect, which intercepts all binary launches and scans new binaries for malware before executing them. |
| 8 | + |
| 9 | +Unfortunately, scanning binaries is done on a single thread and can be fairly slow (100-300ms). This affects projects developed with Cargo, since Cargo creates many binaries that are often only executed once (examples include build scripts and test binaries). |
| 10 | + |
| 11 | +You can avoid this overhead by doing the following: |
| 12 | +- Open `System Settings` and navigate to the `Privacy & Security` item. |
| 13 | +- On older macOS versions, click the `Privacy` tab. |
| 14 | +- Navicate to the `Developer Tools` item. |
| 15 | +- Add your terminal to the list, and enable it. |
| 16 | + - You can run `spctl developer-mode enable-terminal` to add `Terminal.app` to this list. |
| 17 | + - If you use a third-party terminal application, you might need to add that here as well. |
| 18 | +- Restart your terminal. |
| 19 | + |
| 20 | +See the screenshot below for what this looks like on macOS 26 Tahoe. |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +### Security considerations |
| 25 | + |
| 26 | +Unfortunately, there doesn't seem to be a way to scope this to select binaries, e.g. adding Cargo directly as a developer tool has no effect, it has to be the "top-level" process. |
| 27 | + |
| 28 | +As such, **this disables your antivirus for all software that is launched via your terminal**. This is only one part of macOS' security protections that specifically checks for known malware signatures, and it is nowhere near as unsafe as disabling SIP or giving Full Disk Access would be - but depending on your security constraints, you might still consider leaving it enabled. |
| 29 | + |
| 30 | +Changing this setting has not been tested on systems in enterprise environments, it might affect more things there. |
0 commit comments