Build an Xcode Project from the Terminal with xcodebuild

Compile an app by scheme and configuration without launching Xcode.

macOSxcodebuildbuilddeveloperLow risk
Run xcodebuild -project MyApp.xcodeproj -scheme MyApp -configuration Debug build to compile from the command line.

01Command

Command
$ xcodebuild -project MyApp.xcodeproj -scheme MyApp -configuration Debug build

02What it does

xcodebuild drives the same build system Xcode's IDE uses, which makes it the backbone of CI pipelines and scripted builds. List the available schemes first with xcodebuild -list, since the -scheme name must match exactly. Output lands in the DerivedData folder; add -showBuildSettings or -derivedDataPath to control where things go.

03Risk

RiskLow risk
RequirementsXcode or Command Line Tools installed; a valid .xcodeproj or -workspace for CocoaPods projects.
!Warning: A workspace (-workspace X.xcworkspace) must be used instead of -project when the project has CocoaPods dependencies, or build errors follow. Code signing failures are common outside the IDE — add CODE_SIGNING_ALLOWED=NO for a quick local test build.

04Undo

Undo
$ xcodebuild -project MyApp.xcodeproj -scheme MyApp clean

05Sources

  • xcodebuild(1) macOS Manual Page
    Apple man pages (mirror) · vendor-doc · 2026-09-17
    Evidence: Documents xcodebuild -project/-scheme/-configuration and the build and clean actions.

Last verified: 2026-09-18 · Category: Developer

06Related solutions