Afriza N. Arief
Afriza N. Arief

Reputation: 7886

Check Xcode version from command line

How do I check Xcode's version from the command line?

I want to be able to check the version number from scripts or remotely via SSH.

Upvotes: 25

Views: 27683

Answers (2)

Afriza N. Arief
Afriza N. Arief

Reputation: 7886

$ system_profiler SPDeveloperToolsDataType
Developer:

    Developer Tools:

      Version: 6.1.1 (6A2008a)
      Location: /Applications/Xcode.app
      Applications:
          Xcode: 6.1.1 (6611)
          Instruments: 6.1 (56160)
      SDKs:
          OS X:
              10.10: (14A382)
              10.9: (13F26)
          iOS:
              8.1: (12B411)
          iOS Simulator:
              7.1: (11D167)
              8.1: (12B411)

also check out xcrun man page (man xcrun) and xcode-select along with xcodebuild from the other answer.

Upvotes: 36

Green
Green

Reputation: 1761

For mac users, running the below from the terminal will work:

$ xcodebuild -version
Xcode 11.3.1
Build version 11C505

additionally, the exit code is standard 0 for success and 1 if CommandLineTools is configured instead of Xcode

% xcodebuild -version ; echo "# exit code: $?"
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
# exit code: 1

Upvotes: 6

Related Questions