Show Xcode version with xcodebuild -version
xcodebuild -version is the script-friendly way to report exactly which Xcode build is active — more precise than reading the app bundle name, and a standard first line in CI logs.
Run `xcodebuild -version` to print lines like `Xcode 15.4` and `Build version 15F31d`.
01Command
Command
$ xcodebuild -version
xcodebuild -version -sdk02What it does
The flag exits immediately without loading a project, so it is safe to call anywhere in shell scripts. Adding -sdk lists every installed SDK with its version, and because the output depends on the toolchain chosen by xcode-select, it doubles as a check that your build environment points at the Xcode you expect.
03Risk
!Warning: If multiple Xcodes are installed, xcodebuild reports whichever xcode-select points to — verify with `xcode-select -p` when versions look wrong.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- xcodebuild man page (OS X)Evidence: Man page text for xcodebuild covering -version output format.
- xcodebuild(1) macOS man pageEvidence: Documents the -version flag and its -sdk variant printing SDK information.
Last verified: 2026-09-17 · Category: Developer