20

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.

gcamp
  • 14,622
  • 4
  • 54
  • 85
user635064
  • 6,219
  • 12
  • 54
  • 100

5 Answers5

29
  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

Community
  • 1
  • 1
jazzcat
  • 544
  • 7
  • 11
27

Adding libxml2.2.dylib For Xcode 7, Xcode 8.0, Xcode 8.1,

Do the following steps,

  1. Build Phases > Link Binary with Librairies.
  2. Press "Other" button.
  3. After file selection appeared, Press "CMD"+"Shift"+"G"
  4. Type "/usr/lib/"
  5. Select "libxml2.2.dylib"

Thats all.

Community
  • 1
  • 1
Zumry Mohamed
  • 9,318
  • 5
  • 46
  • 51
3

You need to change Always Search User Paths to YES also. That with "${SDK_DIR}/usr/include/libxml2" on your User header search paths should work.

Rodrigo Gonzalez
  • 723
  • 7
  • 15
2

In "Other flags" add -lxml2 And also change the Header to ${SDKROOT}/usr/include/libxml2

Diego Torres
  • 5,308
  • 5
  • 25
  • 29
1

${SDKROOT}/usr/include/libxml2

Alan Zeino
  • 4,406
  • 2
  • 23
  • 30