14

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.

Enadeag
  • 168
  • 1
  • 2
  • 7
  • Alright, reverted the project file to an older state and it fixed my problems. I've checked the build properties which are all the same as before the revert. I'm not sure what went wrong but the app runs again. – Enadeag May 30 '11 at 08:46

2 Answers2

12

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.

Constantino Tsarouhas
  • 6,846
  • 6
  • 43
  • 54
J0S
  • 121
  • 2
  • Sorry for the confusion. Only ment that I tried ${SDKROOT} and ${SDK_DIR} in front of /usr/include/libxml2. But it's fixed now :) – Enadeag May 31 '11 at 12:00
  • 2
    I was able to fix the error by adding `"$(SDKROOT)/usr/include/libxml2"` (including double quotes) in **Targets > Build Settings > Header Search Paths** – Hemang Jan 22 '13 at 05:57
  • @Enadeag: can u please share us how u fixed the above issue for none of the solutions worked for me – sabir Dec 23 '14 at 21:24
  • @Hemang can you tell me steps that helped you compile project successfully – Saraswati Apr 13 '16 at 12:28
5
  • Add libxml2.dylib in Build Phases.
  • Add TFHpple.m, TFHppleElement.m, XpathQuery.m to Build Phases (Compile Sources).
  • Add
    Other Linker Flags: -lxml2 
    Header Search Paths: ${SDK_DIR}/usr/include/libxml2

in PROJECT --> Build Phases and in TARGETS --> Build Phases.

pash3r
  • 141
  • 2
  • 13