# Build arm64 Binaries for Apple Silicon in CI

Canonical: https://figment.so/blog/mac-arm64-binary-ci-apple-silicon

Build with ARCHS=arm64 and ONLY_ACTIVE_ARCH=NO (or swift build --arch arm64) on an Apple silicon host, then fail the job with lipo and a Rosetta check if the arm64 slice is missing.

Run the arm64 CI build on a native Apple silicon host, set `ARCHS=arm64 ONLY_ACTIVE_ARCH=NO` (or `swift build --arch arm64`), and gate the job with `lipo` plus a Rosetta check. A compatible Intel Xcode can cross-compile an arm64 Mach-O, but an Intel host cannot execute arm64 binaries, so it cannot validate them end to end in the same job.

If your macOS CI sits on an Intel runner and you ship a command-line tool or framework, an x86_64 binary will launch on your users' Apple silicon Macs under Rosetta. The job reports green, and users get translated code with higher launch latency and no arm64-specific instructions. This guide closes that gap: force the right build settings, compile natively on Apple silicon, and add a post-build guard that fails the job when the arm64 slice is missing.

## Why do Intel builds silently run under Rosetta?

Rosetta 2 is transparent by design. An x86_64 binary launched on Apple silicon is translated on the fly, prints output, and exits zero. Nothing in the default `xcodebuild` output says a translation happened. If your runner is an Intel Mac, or an Apple silicon Mac invoked through `arch -x86_64`, the resulting binary carries only an x86_64 slice. Per Apple's [Building a universal macOS binary](https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary) note, you can build a universal binary from either platform, but you cannot run or debug the `arm64` slice on an Intel-based Mac. That is the core reason a verification step matters even when the compile succeeds.

## Which build settings produce an arm64 slice?

Two Xcode build settings decide which slices land in the output.

| Setting | Value | Effect |
|---|---|---|
| `ARCHS` | `arm64` | Build only the arm64 slice |
| `ARCHS` | `arm64 x86_64` | Build a universal binary in one pass |
| `ONLY_ACTIVE_ARCH` | `NO` | Respect `ARCHS` regardless of host arch |
| `ONLY_ACTIVE_ARCH` | `YES` | Build only the native arch of the host |

For CI set `ONLY_ACTIVE_ARCH=NO` so the output is not silently reduced to whatever the host happens to be. Pass both on the command line and keep your own scheme name:

```bash
xcodebuild \
  -scheme "$SCHEME" \
  -configuration Release \
  ARCHS=arm64 \
  ONLY_ACTIVE_ARCH=NO \
  build
```

Universal binaries are covered separately in the [Universal Binary CI Pipeline guide](/blog/mac-universal-binary-ci-pipeline).

## How do I build arm64 with Swift Package Manager?

Swift Package Manager accepts `--arch` to pick the destination slice. Without it, `swift build` targets the host architecture, which is fine on an Apple silicon Mac and wrong on Intel.

```bash
# Release build, arm64 slice only
swift build -c release --arch arm64

# Print the product path (do not hard-code it)
swift build -c release --arch arm64 --show-bin-path
```

On an Apple silicon runner, `--arch arm64` is the native architecture, so SPM compiles without cross-compilation overhead. Refer to the [Swift Package Manager documentation](https://www.swift.org/documentation/package-manager/) for the full option list and version differences.

## How do I verify the slice with lipo and file?

After the build, two tools confirm the architecture:

```bash
lipo -archs .build/arm64-apple-macosx/release/"$BIN"
# arm64

file .build/arm64-apple-macosx/release/"$BIN"
# ... Mach-O 64-bit executable arm64
```

A universal binary shows both slices under `lipo -archs`: `x86_64 arm64`. Use `grep -w arm64` (word boundary) to avoid a false match against `arm64e`.

## What post-build guard script should I add?

Add this as the final step of the job. It fails if the runner itself is translated under Rosetta, or if any provided binary lacks an `arm64` slice. The script exits on the first error, so a failed compile cannot be reported as a passing architecture check.

```bash
#!/usr/bin/env bash
# verify-arm64.sh: post-build arm64 slice guard
# Usage: bash verify-arm64.sh <binary> [<binary> ...]
set -euo pipefail

if [ "$#" -eq 0 ]; then
  echo "Usage: $0 <binary> [<binary> ...]" >&2
  exit 2
fi

# Rosetta guard: sysctl.proc_translated == 1 means this shell is translated.
translated="$(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)"
if [ "$translated" = "1" ]; then
  echo "ERROR: CI runner is executing under Rosetta; arm64 output cannot be trusted." >&2
  exit 1
fi

status=0
for binary in "$@"; do
  if [ ! -f "$binary" ]; then
    echo "ERROR: file not found: $binary" >&2
    status=1
    continue
  fi
  archs="$(lipo -archs "$binary")"
  if printf '%s\n' "$archs" | tr ' ' '\n' | grep -qw arm64; then
    echo "PASS  arm64 slice present: $binary ($archs)"
  else
    echo "FAIL  arm64 slice missing: $binary ($archs)" >&2
    echo "      Add ARCHS=arm64 ONLY_ACTIVE_ARCH=NO to xcodebuild," >&2
    echo "      or --arch arm64 to swift build." >&2
    status=1
  fi
done

exit "$status"
```

Invoke it after the build step with the real artifact path from `--show-bin-path`, not a hard-coded guess. This is an untested example; run it against your own project before trusting the exit code in a release job.

## Should I build arm64 or arm64e?

`arm64e` is an extended variant that uses pointer authentication and is reserved for system binaries. For third-party apps shipped through the App Store, Homebrew, or direct download, target `arm64`. Setting `ARCHS=arm64e` on a third-party binary causes codesign and notarization failures. Leave the architecture at `arm64` unless Apple documentation for a specific use case tells you otherwise. If you also run a Windows workstation and want to drive this build remotely, see [Xcode on Windows: remote Mac setup](/blog/mac-xcode-on-windows-remote-setup).

## Can an Intel Mac VM run the arm64 binaries it builds?

An arm64 build and its guard run natively on the [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm) at $39 a month (4 shared vCPUs, 4GB RAM, 65GB SSD), or on the [Dedicated M4 Pro 48 GB](/mac-hosting#dedicated-m4-pro) at $349 a month if you want a whole Mac with 48GB. The Intel Mac VM at $25 a month runs macOS Sequoia and Xcode 26.0 to 26.3. It can cross-compile and sign an arm64 slice, but it cannot execute arm64 output, so it cannot validate the result by running it. Xcode 26.4 and later need macOS Tahoe 26.2 or later, and Xcode 27 needs Tahoe 26.6 or later, so those need an Apple silicon plan.

Entry prices for one Apple silicon runner, taken from each vendor's own pricing page. These are not equal hardware, so compare the hardware column too.

| Vendor | Headline | Notes and source |
|---|---|---|
| Figment Apple Silicon Mac VM | $39/month | 4 shared vCPUs, 4GB RAM, 65GB SSD; 12 × $39 = $468 a year |
| [CloudMac monthly](https://cloudmac.org/pricing) | $99.99/month | M4, 16 GB RAM, 256 GB SSD listed; 512 GB / 1 TB marked fully reserved |
| [CloudMac annual](https://cloudmac.org/) | $999/year | Effective $83.25/month; $531 more per year than 12 × $39 at the Figment VM price |
| [MacStadium M4.S](https://macstadium.com/pricing) | $149/month | M4, 16 GB / 256 GB; pricing page lists support and a 99.99% uptime claim |

CloudMac's M4 has 16 GB where the Figment VM has 4GB and shared vCPUs, so the cheaper price buys a smaller machine. Figment runs the Mac and network; you manage your CI and apps. If you also work from a Windows workstation and want to drive this build remotely, see [Xcode on Windows: remote Mac setup](/blog/mac-xcode-on-windows-remote-setup).

**Related guides:**
- [Universal Binary CI Pipeline for macOS Apps](/blog/mac-universal-binary-ci-pipeline)
- [Sign iOS Builds with App Store Connect API Key](/blog/mac-app-store-connect-api-ci-signing)
- [Xcode on Windows: Remote Mac Setup](/blog/mac-xcode-on-windows-remote-setup)
