How to Build a Universal Binary in GitHub Actions
Build for both arm64 and x86_64, then combine the slices into one universal binary with lipo -create, or let xcodebuild emit both arches at once.
With xcodebuild, set ARCHS="arm64 x86_64" and ONLY_ACTIVE_ARCH=NO. For raw tools, build each arch separately and merge them with lipo -create -output.
Steps
- For Xcode: build with
ARCHS="arm64 x86_64" ONLY_ACTIVE_ARCH=NO. - For swiftc/clang: build each slice, then
lipo -createthem. - Verify the result with
lipo -info <binary>.
Workflow
.github/workflows/ci.yml
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Build both slices
run: |
swiftc -O -target arm64-apple-macos11 main.swift -o app-arm64
swiftc -O -target x86_64-apple-macos11 main.swift -o app-x86_64
- name: Make universal
run: |
lipo -create -output app app-arm64 app-x86_64
lipo -info appGotchas
lipo -infoshould report botharm64andx86_64; if not, one slice failed to build.- Every dependency you link must also be universal, or the merge fails on the missing arch.
Related guides
How to Build on Apple Silicon in GitHub ActionsRun a build on an Apple Silicon (arm64) GitHub Actions runner by selecting an M-series image such as macos-14…
How to Build a macOS App With xcodebuild in GitHub ActionsBuild a macOS app on a GitHub Actions runner with xcodebuild build, targeting the platform=macOS destination…