Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find Xcode installation path by version

There are no standard paths to keep different copies of XCode (XCode3 and XCode4) on one system. For my Makefile or other commandline based build process, I am searching for a way to determine to installation path ($DEVELOPER_DIR) of XCode of a specific version, to export this path as DEVELOPER_DIR or use xcode-select to make it active.

So far I am trying to query system_profiler's xml output.

Are there any other (more convenient) options?

Basically I need a script to tell the system to use Xcode3 (or Xcode4) without knowing their installation paths.

like image 933
tonklon Avatar asked Nov 14 '22 23:11

tonklon


1 Answers

Here's what I have come up with so far:

DEVELOPER_DIR=`system_profiler SPDeveloperToolsDataType -xml |\
xpath "//*[text()='spdevtools_version']/following-sibling::string[starts-with(text(),'3')]/../*[text()='spdevtools_path']/following-sibling::string[1]/text()"`

This sets DEVELOPER_DIR to the installation path of Xcode3. For Xcode4 just replace the '3' by '4'

This will not work as expected when multiple versions of XCode3 are installed.

like image 166
tonklon Avatar answered Dec 26 '22 12:12

tonklon