iPhone libxml2 not found during build

Enadeag picture Enadeag · May 30, 2011 · Viewed 10.4k times · Source

I currently got some errors with libxml2 in my iPhone project. This was working before, after making some changes in my build properties building failed. (libxml2.dylib is added in the build phases)

#import <libxml/tree.h>
#import <libxml/parser.h>
#import <libxml/xmlstring.h>
#import <libxml/xpath.h>
#import <libxml/xpathInternals.h>

I've added the following items to the Build Settings:

Other Linker Flags: -lxml2
Header Search Paths: /usr/include/libxml2

I've tried adding them to the project and targets (at the same time, and switching between them) without any difference.

I also tried adding the following to the Header Search Path:

${SDKROOT}
${SDK_DIR}

Both with no result.

Building fails for: iPhone device iPhone and iPad emulator

Anyone have an idea?

I'm using the GData Objective-C client library: http://code.google.com/p/gdata-objectivec-client/ I'm compiling the source files directly into my project and followed all the steps that are given in the wiki. When manually importing the libxml headers again, XCode suggests the following:

#import <libxml2/libxml/tree.h>

Which doesn't work either.

Answer

J0S picture J0S · May 31, 2011

Add ${SDKROOT}/usr/include/libxml2 as a header search path instead of only ${SDKROOT}.

Watch out that you all build targets that need libxml get the extra search path. If you add the path to your project's build settings, all its targets will inherit it and there shouldn't be a problem.