Search code examples
xcodemacosxcodebuildbuild-system

Configuring Xcode project to be built with specific build tools version


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?


Solution

  • 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