xcodebuild
TLDR
Build a project with default settings
SYNOPSIS
xcodebuild [-project name] [-workspace name] [-scheme name] [-target name] [-sdk sdk] [-destination dest] [action...]
DESCRIPTION
xcodebuild is Apple's command-line tool for building Xcode projects and workspaces. It performs build, test, archive, and export operations, making it essential for CI/CD pipelines and automated builds of macOS, iOS, watchOS, and tvOS applications.
The tool works with projects (.xcodeproj) or workspaces (.xcworkspace). Workspaces, commonly used with CocoaPods or Swift Package Manager, require specifying a scheme. Schemes define which targets to build and with what configuration.
Building for iOS distribution is typically a two-step process: first archive to create an .xcarchive, then -exportArchive with an export options plist to produce the final .ipa file. Code signing and provisioning can be managed automatically with -allowProvisioningUpdates.
PARAMETERS
-project name
Build the project specified by name.xcodeproj.-workspace name
Build the workspace specified by name.xcworkspace.-scheme name
Build the scheme with the specified name. Required for workspaces.-target name
Build the target with the specified name.-sdk sdk
Build with the specified SDK (iphoneos, iphonesimulator, macosx).-destination destination
Use the destination described by destination.-configuration config
Build configuration: Debug or Release.-archivePath path
Path for archive output.-exportPath path
Path for export output.-exportOptionsPlist path
Plist file specifying export options.-list
List all targets, schemes, and configurations.-showsdks
List all available SDKs.-allowProvisioningUpdates
Allow automatic provisioning profile management.build
Build the target (default action).archive
Create an archive for distribution.test
Run unit tests.clean
Remove build products.
CAVEATS
Requires Xcode installation (not just Command Line Tools). Use `xcode-select -s` to switch developer directories if needed. Archive and export require valid code signing identities and provisioning profiles. Simulator destinations require the simulator to be installed.
HISTORY
xcodebuild has been part of Xcode since its early versions, evolving alongside Apple's development tools. The tool has grown significantly more powerful, adding workspace support, destination specifiers for simulators and devices, and xcpretty-compatible output. It remains the foundation for iOS and macOS continuous integration systems.
SEE ALSO
xcrun(1), xcode-select(1), codesign(1), swift(1)


