Building Xcode Projects From The Command Line In 2026

1 min readiOS Development, Xcode & Tools

Jake Marsh

In 2012 I wrote about a couple of little tools that made building Xcode projects from the command line less painful. Both were Ruby scripts wrapped around xcodebuild.

I still build almost everything from the command line. Here’s what that looks like for me now.

XcodeGen#

Every Apple project I start now begins with a project.yml and XcodeGen. The .xcodeproj gets generated from that file, so I never hand-edit a project.pbxproj or untangle a merge conflict in one.

Here’s a whole project file for a small Mac command line tool:

YAML
name: TodoDemo
options:
  bundleIdPrefix: com.example
targets:
  TodoDemo:
    type: tool
    platform: macOS
    deploymentTarget: "15.0"
    sources: [Sources]

Run xcodegen next to it:

⚙️  Generating project...
⚙️  Writing project...
Created project at /Users/jake/TodoDemo/TodoDemo.xcodeproj

Add a file, a target or a build setting by editing the YAML and running it again.

xcodebuild#

Then a plain xcodebuild builds it:

Shell
xcodebuild -project TodoDemo.xcodeproj -scheme TodoDemo -derivedDataPath build build

-derivedDataPath puts the build output in the project folder instead of ~/Library/Developer/Xcode/DerivedData, which makes it easy for a script to find the product, and easy to delete.

Any build setting can be overridden right on the command line by tacking NAME=value onto the end. One I like turning on now and then makes the Swift compiler warn about anything slow to type-check:

Shell
xcodebuild -project TodoDemo.xcodeproj -scheme TodoDemo build \
  OTHER_SWIFT_FLAGS='-Xfrontend -warn-long-expression-type-checking=100 -Xfrontend -warn-long-function-bodies=100'

Anything over 100 ms becomes a warning like this one (from a test where I turned the limit way down to 1 ms):

Sources/main.swift:4:12: warning: expression took 27ms to type-check (limit: 1ms)

And when I need to know what a setting ended up as, -showBuildSettings prints all of them:

Shell
xcodebuild -project TodoDemo.xcodeproj -scheme TodoDemo -showBuildSettings | grep -E " (PRODUCT_BUNDLE_IDENTIFIER|MACOSX_DEPLOYMENT_TARGET) ="
    MACOSX_DEPLOYMENT_TARGET = 15.0
    PRODUCT_BUNDLE_IDENTIFIER = com.example.TodoDemo

xcbeautify#

xcodebuild is loud. That one-file tool above printed about 600 lines for a single build. xcbeautify boils it down to the parts you’d want to read:

Shell
xcodebuild -project TodoDemo.xcodeproj -scheme TodoDemo build | xcbeautify
[TodoDemo] Compiling main.swift
[TodoDemo] Copy arm64-apple-macos.abi.json -> TodoDemo.abi.json
Build Succeeded

One gotcha when you use it in a script: the exit status of a pipeline is the last command’s, so a failed build piped into xcbeautify still exits 0. Put set -o pipefail at the top of the script and a failed build fails the script too.

Both XcodeGen and xcbeautify install with Homebrew (brew install xcodegen xcbeautify). Kinda neat that both of them are written in Swift.