Should DEVELOPER_DIR remain in the environment?

I would like to have side-by-side installation of Xcode and use an environment variable DEVELOPER_DIRto choose between them. The purpose of this is to use the result xcrun -f --sdk macosx clangto determine the appropriate C compiler, and then use it in the script system or assembly.

CC=$(DEVELOPER_DIR=<something> xcrun -f --sdk macosx clang)

My question is whether it should DEVELOPER_DIRremain installed when using the tools found with the help xcrun, or whether it is possible to simply install it at runtime xcrun, as done above, and then use the returned tools in the default environment, without it DEVELOPER_DIRalready installed.

In other words, although it xcrunclearly depends on the value DEVELOPER_DIR, do the tools themselves also depend on it? Is there a significant difference between:

  • DEVELOPER_DIR=<whatever> command CC=$(xcrun -f --sdk macosx clang)
  • command CC=$(DEVELOPER_DIR=<whatever> xcrun -f --sdk macosx clang)

Is the second correct? Or just the first?

+6
source share
1 answer

I would like to have the Xcode installation side by side and use the DEVELOPER_DIR environment variable to choose between them.

, Xcode. xcode-select, , , , , DEVELOPER_DIR . --switch:

, /Applications/Xcode -DP.app. (. sudo (8)) . shell, DEVELOPER_DIR (. ).

, " ":

, Xcode (,/Applications/Xcode.app/Contents/Developer). Xcode - , .

, <whatever> Developer, Xcode.

, xcrun DEVELOPER_DIR, ? :

DEVELOPER_DIR=<whatever> command CC=$(xcrun -f --sdk macosx clang)

xcrun, , , DEVELOPER_DIR . xcode-select "" DEVELOPER_DIR. "" Xcode /usr/bin. , '/usr/bin/clang' , xcrun, /usr/bin/clang clang DEVELOPER_DIR. , , - script, script DEVELOPER_DIR, /usr/bin.

command CC=$(DEVELOPER_DIR=<whatever> xcrun -f --sdk macosx clang)

. clang , , DEVELOPER_DIR . , , , , - . , , , - , , , xcodebuild, , , DEVELOPER_DIR, .

, DEVELOPER_DIR script, xcrun , .

+1
source

Source: https://habr.com/ru/post/1015840/


All Articles