Which version of Xcode does xcodebuild use?
Asked Answered
H

4

67

I have installed both Xcode 3.2 and Xcode 4.0.2 on the same machine, which uses Hudson for automated CI (continuous integration) builds. When I say that both were installed, what I mean by that is that I can use both Xcode 3 and Xcode 4 simultaneously or interchangeably. They both exist on the machine, as I did a custom install for Xcode 4 without overwriting Xcode 3 (supposedly).

  • Do command line calls to 'xcodebuild' invoke Xcode 3 or Xcode 4?
    • Does that question even make sense? Someone who may or may not be knowledgable on the topic is requesting that some projects be built with 3 and some with 4.
  • If so, how do I force it to use 3 or 4?
    • alternatively, is there a separate location where Xcode 3's 'xcodebuild' is stored vs. where Xcode4's 'xcodebuild' is stored? If there is, I can just use a different path in my build script.
Highup answered 10/8, 2011 at 19:6 Comment(2)
found it! by default, xcodebuild is stored in Developer/usr/bin. I have Xcode4 stored separately in a folder called Xcode4 so the xcodebuild path for xcodebuild is Xcode4/usr/bin/xcodebuild. This means I will replace 'xcodebuild' in my build script with 'Xcode4/usr/bin/xcodebuild'. I'll let you know if it DOESN'T work.Highup
What about using 'which -a xcodebuild' to find all the locations in your path where xcodebuild exists. For example in my case this returns '/usr/bin/xcodebuild'. Since this is on the path, issuing 'xcodebuild -version' returns that I have Xcode 4.5.Carbazole
M
147

You can find out what version is xcodebuild using with xcode-select -print-path. Also, change to a different version using xcode-select -switch <path>

Mightily answered 17/8, 2011 at 10:20 Comment(1)
For me, I had to use sudo to switch path.Gaylagayle
S
51

Also, to determine which XCode environment is being used, use the command xcodebuild -version.

Surovy answered 25/9, 2012 at 4:40 Comment(1)
You may well need to specify where xcodebuild is located, for example if you have Xcode installed, it will probably be here: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuildKatelynnkaterina
P
30

Outside the terminal, you can view and change this in Xcode.

Open Preferences, then select the Locations tab. Near the bottom, an entry titled Command Line Tools labels a dropdown, whose selection corresponds to the version of Xcode used in xcodebuild.

You may open this dropdown to select another version of Xcode that you have installed in your /Applications or ~/Applications folder.

Screenshot illustrating the above-described solution.


Interestingly, this panel only says what this pop-up menu does and that it's analogous to xcode-select if you've selected a different version of Xcode than the one it's running in.

In case you need it, I also have a screenshot from what this used to look like in Xcode 8.

Palawan answered 16/6, 2017 at 18:19 Comment(0)
I
1

One reason we don't use xcode-select is we are not admin or not in sudo list. we can choose the xcodebuild and not use the default one.

Run xcode-select -p and we might get /Applications/Xcode.app/Contents/Developer, and the xcodebuild is in this folder /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild

So if we have installed another Xcode, find the folder and along with that xcodebuild.

Infrastructure answered 12/4, 2023 at 9:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.