Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
522 views
in Technique[技术] by (71.8m points)

macos - How to add a global include path for xcode

I'd like to add ~/include to my include path for all projects while using Xcode, something like setting the environment variable CPLUS_INCLUDE_PATH in Linux. (See here for the related Linux question.)

Is this possible in Xcode? I tried setting the above environment variable, but it doesn't seem to work. (And if it is possible, I'd like to also set related paths, like LIBRARY_PATH and LD_LIBRARY_PATH.)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

According to Apple's Docs, you are able to provide a default for any build setting using an environment variable.

In this case, you'd want to set HEADER_SEARCH_PATHS. For some reason I don't understand, this doesn't work. It works fine for other build settings (for example, OTHER_CFLAGS), but not for HEADER_SEARCH_PATHS. You can see what the variable name for any setting is by opening the research assistant in the build settings window (book button on the bottom left.)

One var that does work is USER_HEADER_SEARCH_PATHS, which is just like what you want, but only works for paths in double quotes (not in angle brackets.)

So

#include "bar.h"

would work, but

#include <bar.h>

wouldn't.

The build settings plist referenced from the above article on environment variables should end up looking something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>USER_HEADER_SEARCH_PATHS</key>
    <string>~/test</string>
</dict>
</plist>

Hope that helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...