Question

in my project, I want to refer to an other xcconfig file, located in InDesign SDK. As this SDK may be installed at different locations, depending upon the machine, I prefer to declare an environment variable for locating it.

Nest step is obviously to use variable (aptly named ID_CS5_SDK_DIR) in my xcconfig include directive.

Unfortunatly, when I try the 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 a

 [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 ?

Was it helpful?

Solution

I've been trying to do this too and also came to the conclusion that it is not possible.

OTHER TIPS

I once tried to achieve that and came to the conclusion that you can't. I would be happy if someone proves us it's possible though then delete my answer

It seems like .xcconfig files can only DEFINE and set value to environment variables (which prevail only throughout the build session) but not USE or evaluate environment variables.

Maybe it is because .xcconfig files serve as a base layer of build-settings, and are not parsed.

Unfortunately this is not possible, but instead of making one include the other, you can use two different xcconfig files per target. Just select one for the Project and one for the Target.

enter image description here

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

Short Instructions for experienced users:

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

Steps For Inexperienced Users

  1. Open Application/Utilities/Terminal, and enter

    sudo nano /etc/launchd.conf

  2. Create the Environment Variable by adding a line like

    setenv VARIABLENAME FOLDER/PATH

    and then pressing ENTER.

  3. Save the file using Ctrl-O, Ctrl-M, (Possibly Ctrl-Y to overwrite), then Ctrl-X to exit the editor.
  4. (Optional) type cat /etc/launchd.conf to see that your changes are present
  5. Restart your computer. (Logoff doesn't work)
  6. You can now access the variable in your .xcconfig file as

    $(VARIABLENAME)

Notes:

  • This creates a GLOBAL environment variable, accessible to all users. It probably doesn't make sense to set this to something in your home directory (e.g ~/MyFolder). If you do this, however, you need to use the full pathname, such as /Users/MyUserName/MyFolder).

References:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top