Adding libxml2 in XCode

user635064 picture user635064 · May 16, 2011 · Viewed 21.5k times · Source

I have added libxml2 to my Xcode 4 project following this guide.

But it's not working. Xcode gives me error saying it no such libxml2 directory. What am I doing wrong? Here's the screenshots of the target settings of my project: enter image description here

enter image description here

Thanks.

Answer

jazzcat picture jazzcat · Dec 17, 2011
  1. add ${SDKROOT}/usr/include/libxml2 to "Header Search Paths" instead of "User Header Search Paths" under yourtarget -> Build Settings -> Search Paths
  2. link with libxml2.dylib in yourtarget -> Build Phases -> Link Binary With Libraries
  3. include libxml2 headers with, for instance, #include <libxml/HTMLparser.h> and you're off

for better explanation see to this answer https://stackoverflow.com/a/3429301/149663