Configuring Xcode project to be built with specific build tools version

1.4k views Asked by At

In my build system, I am using xcodebuild to build multiple projects.

I want to configure different Xcode installation to be used per project.

I know about sudo xcode-select --switch <path>, but:

  • This option is system-wide, and might mess up with other parallel builds.
  • It requires root, which I prefer to avoid (since it's an automatic build system).
  • It is not configured internally in the project.

Is there a way to specify the build tools path to use per project?

2

There are 2 answers

0
Mats On BEST ANSWER

From the output of xcrun:

The active developer directory can be set using xcode-select, or via the DEVELOPER_DIR environment variable. See the xcrun and xcode-select manual pages for more information.

E.g. to run xcodebuild with a specific Xcode-installation:

$ DEVELOPER_DIR=/path/to/my/Xcode.app/Contents/Developer xcodebuild

In a bash script:

export DEVELOPER_DIR=/path/to/my/Xcode.app/Contents/Developer

xcodebuild
1
NSDmitry On

You can probably launch xcodebuild directly from Applications/Xcode.app/Contents/Developer/usr/bin, so modifying the path you will use different Xcode version.