Using M1 Mac Mini’s to power our GitHub Actions iOS CI

Image for post
Image for post

TL;DR:

arch -arm64 /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild ...

Full story

Image for post
Image for post
arch -x86_64 ./run
ONLY_ACTIVE_ARCH=false
The arch_name argument must be one of the currently supported architectures:i386    32-bit intelx86_64  64-bit intel
function needsArmFlag(): boolean {
const isArm = execSync(`uname -m`).toString().trim() === "arm64";
let isM1 = false;
try {
// this command will only succeed on m1 macs.
execSync(`arch -arm64e echo hi`);
isM1 = true;
} catch (err) {
// Must not be an m1 mac
}
return isM1 && !isArm;
}
$ file /usr/bin/xcodebuild
/usr/bin/xcodebuild: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]

$ find /Applications/Xcode.app/Contents/Developer -name “xcodebuild”
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild

$ file /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
const buildCommand = [
needsArmFlag() ? "arch -arm64" : '',
"/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild",
...,
]).join(' ')

Screenplay Cofounder, Former Airbnb Software Engineer, Harvard CS ‘17

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store