Mac OS X Xcode Libraries
If you want to add default include and search paths that persist across all projects, you need to use:
For include paths:
CPATH
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH
And for library paths:
LIBRARY_PATH
In order for Xcode and other GUI applications in OS X (tested on 10.10) to be able to access these environment variables, you need to set variables using:
/bin/launchctl setenv LIBRARY_PATH /usr/local/lib
/bin/launchctl setenv CPATH /usr/local/include
But these are not permanent. In order to have these variables across restarts, you need to create a startup script. See this page for an example.
This is my personal applescript file which I have saved as an Application in iCloud (so it survives reformats) and have set as a startup item in system preferences->users and groups->login items.
set ENV_LIBRARY_PATH to "/bin/launchctl setenv LIBRARY_PATH /usr/local/lib;"
set ENV_CPATH to "/bin/launchctl setenv CPATH /usr/local/include;"
do shell script ENV_LIBRARY_PATH & ENV_CPATH
As for adding them to the dialog, there are two ways which i have found:
The quick and dirty way:
sudo ln -s /usr/local/lib/ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib
This will add all of your lib files from /usr/local/lib to the dialog under the same OS X 10.10 "folder" in the dialog.
The second way involves creating your own .sdk directory with a usr subdirectory in
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
, then copying over the SDKSettings.plist from/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/SDKSettings.plist
to your .sdk directory, editing it using Xcode, and symlinking your /usr/local/bin, /usr/local/include /usr/local/lib to your mydir.sdk/usr/ directory.