27

I've been referencing a lot of Projects, and i do it through adding their paths in Header Search Paths.

I've been following the referencing stuffs through the "Referenced Project's" getting Started (like for example including the ZXingWidget).

And I've been doing it a lot now, but I don't understand the checking of recursive.

  1. What does this mean?
  2. When do I check a path for "recursive?"

Thanks

Vincent Bacalso
  • 2,071
  • 4
  • 23
  • 34

4 Answers4

24

If you give Xcode a path to use for headers, it will check that path when you use an #include or #import statement. If the file isn't there, it quits.

If you have the path set as "recursive", Xcode will search folders it finds there if it doesn't find the file.

Looks like this:

enter image description here

Almo
  • 15,538
  • 13
  • 67
  • 95
  • 1
    But how do you set it as "recursive"? – shim Oct 18 '12 at 20:14
  • 4
    When you add a search path in the build settings, there's a box to check to set recursive. – Almo Oct 19 '12 at 00:22
  • 1
    I don't see that. What I did do was add /** to the end of it. Does that do the same thing? – shim Oct 19 '12 at 01:40
  • 1
    There's an image of it here. http://iphoneincubator.com/blog/xcode/how-to-add-multiple-static-library-files-with-different-architectures-to-xcode – Almo Oct 19 '12 at 09:06
  • Followup: If your include uses folders e.g. `#include ` then do you need to specify recursive or not? – Hamy Jan 29 '13 at 21:24
  • I would assume not, though I do not know for sure. – Almo Jan 30 '13 at 02:38
  • You have to double click on the path, which brings up a window that has the "recursive" option. Utterly infurating and not intuitive, imo. – user124384 Jun 21 '15 at 04:23
  • For future users, click "+" and enter `$(PROJECT_DIR)` as the value in the field, then set it to recursive, and it will crawl all folders to find your .h files. – Albert Renshaw Jan 08 '20 at 20:54
13

1) Enter your desired path for Header Search Paths, click enter.

2) Double click the path text that you entered.

3) On the right of the dialog box select recursive.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
user2460799
  • 139
  • 1
  • 2
5

For those wondering, as I was, what the effect of choosing recursive for a Header Search Path is on the compiler command line, it's to generate a -I argument for every directory in the tree rooted at the given path. This can lead to very long compiler command lines which will make looking for anything else in there well nigh impossible. So it's worth considering how many directories are below the path you are specifying if you want to use recursive.

I tried specifying -I../path/to/subproject/** as a Compiler Flag for an individual file but that doesn't work (which is obviously why Xcode does the expansion itself).

(this is true for Xcode 9.4.1)

Perry
  • 1,152
  • 10
  • 14
2

Xcode Recursive path

When you set a path(e.g. Header Search Paths, Library Search Paths, Framework Search Paths...) you can define a path to one of parent folder and set recursive(/** will be added to the end of the path). For example you can defile a path to a include directory(or more over to a Build directory) with recursive parameter instead of include/<target_name>.

Please note: If the patch contains spaces - , you should escape them using \ or enclose the path in double quotes ""

yoAlex5
  • 29,217
  • 8
  • 193
  • 205