Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Header search paths for subproject in XCode

I added a subproject (a library) to my project.

In order to be able to import the header files of the subproject, I'm adding the absolute path to the subproject directory (recursive) to the "Header Search Paths" of my main project. Is there anyway to configure XCode to automatically/ dynamically recognise the path to my subproject directory?

I feel that what I'm doing right now is very manual and prone to human errors. Also, in case I moved my subproject, I will not be able to import its header files anymore.

Note that I don't want to put the subproject directory inside the same directory with the main project as it will be reused for many different projects.

The reason why I expected this functionality of XCode are:

  1. XCode allows me to drag and drop my library project into the main one, which is an intuitive and dynamic way of including library. It should not, therefore, require me to manually put in the path to the main project's build settings.
  2. When we drag and drop our files and directories into an XCode project, it seems to handle the XCode's references and the filesystem paths smoothly. I don't understand how the logic differs for header search paths for subprojects?
like image 429
ericn Avatar asked Oct 15 '14 08:10

ericn


1 Answers

You can use a relative directory, as opposed to an absolute directory, by using $(PROJECT_DIR), which is one of Xcode's many variables.

Assuming the sub-project is in a sibling directory to the app project (a system I use myself), then set Header Search Path to (something like):

$(PROJECT_DIR)/../libproject/include

This will allow the project to exist anywhere in the filesystem, provided the project directories maintain the same relative path to each other.

like image 116
Droppy Avatar answered Oct 19 '22 02:10

Droppy