1

I have this problem with a library. I want to add it to my Objective C (iOS) project, but their docs don't say how to do that. I simply copied it over. Now their main file has this:

#include <LIB/Class1.h>
#include <LIB/Class2.h>
...

It didn't work for me, so I changed each <> to "":

#include "LIB/Class1.h"
#include "LIB/Class2.h"
...

And with this syntax everything works fine, I can use the lib. I guess it's not a good practice, though. How should I add a library to a project so that it works without this modification?

itarato
  • 795
  • 1
  • 8
  • 24

3 Answers3

4

In Xcode Build Setting, Header Search Paths (HEADER_SEARCH_PATHS) affects search path of #include <foo.h>, User Header Search Paths (USER_HEADER_SEARCH_PATHS) affects search path of #include "foo.h".

So, set HEADER_SEARCH_PATHS for your library's header path, #include <LIB/Class1.h> should be work.

Also, Always Search User Paths (ALWAYS_SEARCH_USER_PATHS) setting can change behavior for search path #include <foo.h>. When ALWAYS_SEARCH_USER_PATHS is YES, #include <LIB/Class1.h> should be work as well.

Kazuki Sakamoto
  • 13,929
  • 2
  • 34
  • 96
  • Thanks! I did what you said (HEADER_SEARCH_PATHS + ALWAYS_SEARCH_USER_PATHS) but I still had to add all the files into my project. Is it normal? – itarato Feb 27 '11 at 17:21
  • need not to add files into your project. How do you set HEADER_SEARCH_PATHS and how are your project path and library path? – Kazuki Sakamoto Feb 27 '11 at 20:59
0

Add path to the libpath... "" relative from source and <>relative from the external libs

rylg
  • 1
0

ALWAYS_SEARCH_USER_PATHS is deprecated now & should be avoided. Explicitly set

  • USER_HEADER_SEARCH_PATHS for ".h" include syntax header files.
  • SYSTEM_HEADER_SEARCH_PATHS for <.h> include syntax header files.
  • HEADER_SEARCH_PATHS: for fallback of USER_HEADER_SEARCH_PATHS for compilers which don't support separate include paths.

https://help.apple.com/xcode/mac/current/#/itcaec37c2a6?sub=deved642222b