How to use environment variable in xcconfig #include?

in my project, I want to refer to another xcconfig file located in the InDesign SDK. Since this SDK can be installed in different places, depending on the machine, I prefer to declare an environment variable to define it.

The Nest step obviously should use a variable (aptly named ID_CS5_SDK_DIR ) in my include xcconfig directive.

Unfortunately, when I try simple

 // InDesign sdk project build settings (based on common build settings) #include "$(ID_CS5_SDK_ROOT)/build/mac/prj/_shared_build_settings/common.xcconfig" 

Xcode throws me

  [WARN]AutocatPlugin.xcconfig line 7: Unable to find included file "$(ID_CS5_SDK_ROOT)/build/mac/prj/_shared_build_settings/common.xcconfig" 

How can I make it work?

+4
source share
5 answers

I also tried to do this, and also came to the conclusion that this is impossible.

+5
source

Once I tried to do this and came to the conclusion that you cannot. I would be happy if someone proves to us that this is possible, but then delete my answer

+3
source

It seems that the .xcconfig files can only DEFINE and set the value for environment variables (which prevail only during the build session), but do not use USE or evaluate environment variables.

Perhaps this is because .xcconfig files serve as the basic level of build settings and are not parsed.

0
source

Unfortunately this is not possible, but instead of including one of them, you can use two different xcconfig files for each purpose. Just pick one for Project and one for Target.

enter image description here

0
source

If you put the environment variable in /etc/config/launchd.conf and then reboot, it will be available for the .xcconfig file.

Brief instructions for advanced users:

Edit the read-only file /etc/launchd.conf and add 'setenv VARIABLENAME / FOLDER / PATH' to the file, then reboot.

Steps for inexperienced users

  • Open the application / Utilities / terminal and enter

    sudo nano /etc/launchd.conf

  • Create an environment variable by adding a string like

    setenv VARIABLENAME FOLDER/PATH

    , then press ENTER.

  • Save the file with Ctrl-O, Ctrl-M (maybe Ctrl-Y to overwrite), then Ctrl-X to exit the editor.
  • (Optional) type cat /etc/launchd.conf to see that your changes are present.
  • Reboot the computer. (Logout does not work)
  • Now you can access the variable in your .xcconfig file as

    $(VARIABLENAME)

Notes:

  • This creates a global environment variable that is accessible to all users. It probably doesn't make sense to set this in your home directory (e.g. ~ / MyFolder). However, if you do, you need to use the fully qualified path name, e.g. / Users / MyUserName / MyFolder).

Literature:

-4
source

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


All Articles