Re: Headers in folder references
Re: Headers in folder references
- Subject: Re: Headers in folder references
- From: Rick Mann <email@hidden>
- Date: Mon, 30 Jul 2012 02:13:06 -0700
Yep, knew that, too. But what still seems to be the case is that it only does that for header files added to the project directly, rather than in folder references. Seems to me it should do it for both. Not sure if that's a bug or feature, or if there's a way to tell it to include those folders in the search paths. I generally dislike having to set the build setting.
--
Rick
On Jul 30, 2012, at 1:10 , Jean-Daniel Dupas <email@hidden> wrote:
> Xcode uses header map files (.hmap) which contains the list of target's headers and pass these files to the compiler as header search paths.
>
>
> Le 30 juil. 2012 à 09:52, Rick Mann <email@hidden> a écrit :
>
>> I'm pretty familiar with how GCC (and other compilers) search for headers. What's not clear is how Xcode adds search paths on your behalf, based on what's included in the project. Headers added seem to be searched, but headers referenced inside a folder reference do not.
>>
>> --
>> Rick
>>
>>
>>
>> On Jul 30, 2012, at 0:30 , Andreas Grosam <email@hidden> wrote:
>>
>>>
>>> On 28.07.2012, at 05:34, Rick Mann wrote:
>>>
>>>> Hi. I'm including a folder reference in my iOS project to a folder that receives some generated C headers. They don't seem to be available to the rest of my code for #import directives. Do I need to expressly add a search path to the project for that folder?
>>>
>>> A compiler -- or better the Preprocessor -- only knowns the system paths by default.
>>>
>>> Xcode, on the other hand, performs some "magic" which adds a few header and framework search paths to a project which are likely to be used, and it also generates a "header search map" from the header files added to a project which makes it convenient (from the perspective of the user) to include/import headers through an unqualified include/import directive from a source file anywhere in a project without the need to add paths explicitly. Beyond this, Xcode does not do any further "magic".
>>>
>>>
>>> This convenience comes at a cost, however:
>>>
>>> Developers not familiar with a raw C compiler (and preprocessor), but starting with Xcode or other IDEs never had to grasp thoroughly how search paths actually do work for a compiler (preprocessor). So, you should first make yourself familiar with this topic ;)
>>>
>>> Second, if you are in doubt which header search paths are set when compiling a certain module - check the transcript for search paths options:
>>> -I and
>>> -iquote
>>>
>>> You can also set option "-v" in the "Other C Flags" option build settings, which makes the compiler driver output the search paths.
>>>
>>>
>>> Sometimes you have to set header search paths. Often time you **should** set a path, even though Xcode had set one. But in order to avoid header search paths conflicts, and also make it more clear in the sources where a header is located it is better to set a header search path.
>>>
>>> For example, suppose you have a header file "MyHeader.h" located in
>>> $(SRCROOT)/MyProject/Sources/MySubmodule
>>>
>>> #import "File.h"
>>>
>>> *might* work without any additional work, if Xcode happens to references this file and was able to create a "header map" which created the header search path and is used "automagically". Now suppose, for any reason **and for clarity** you want to include that header more explicitly:
>>>
>>> You can add a header search path, e.g.:
>>> $(SRCROOT)/MyProject/Sources
>>>
>>> and then importing the header with a qualified include directive:
>>>
>>> #import "MySubmodul/MyHeader.h"
>>>
>>> This way, you also will likely remove any possible header conflicts with other headers named "MyHeader.h" where also a path exists in your project. And note: Xcode adds a few paths *automatically*, which increases the possibility for a header conflict.
>>>
>>>
>>> Note that you can add "relative paths" as header search paths. The paths are relative to $(SRCROOT). So adding
>>> MyProject/Sources/MySubmodul is equivalent to
>>> $(SRCROOT)/MyProject/Sources/MySubmodul
>>>
>>> Avoid spaces in any path!
>>>
>>>
>>> Further readings:
>>> < http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html >
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Xcode-users mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Xcode-users mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> -- Jean-Daniel
>
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden