Tired of having to change my header and library search paths in every project to be able to link libraries from homebrew in /usr/local/lib
and /usr/local/include
.
Is there a way to make Xcode recognize those two search paths by default? ld
states it uses those search paths by default but it seems Xcode does not.
Also, is there a way to add my libraries from /usr/local/lib
to this dialog without having to select add other?
Best Answer
If you want to add default include and search paths that persist across all projects, you need to use:
For include paths:
And for library paths:
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:
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.
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.