45

I just installed Xcode version 4.3.1 and I get this error:

libxml / tree.h file not found

I have also installed Xcode 4.2, and with the same project I get the same error.

I have configured the header search paths with /usr/include/libxml2
I also tried $(SDKROOT) / usr/include/libxml2 and it didn't work.

I have also put Other Linker Flag with lxml2

0

14 Answers 14

100

Include the following in your header search path and you should be immune to any weirdness Apple does with their Xcode updates:

$(SDKROOT)/usr/include/libxml2 
Sign up to request clarification or add additional context in comments.

3 Comments

This worked for me, but I also had to set to YES to "Always Search User Paths"
This worked for me with setting Always Search User Paths to NO
Just in case anyone is in the same situation I was: remember to add the search path also to the test target.
27

In your question, you have a space between the / and usr. Perhaps this is a typo, but the path is:

/usr/include/libxml2 

Just confirm that is the path in the target build settings:

Target build settings

You can also verify that the path exists on your file system.

3 Comments

This free space must have been a mistake to copy and paste ... I have marked the option to Always Search User Path to YES, and does not work: (
Are you importing the header like: #import <libxml/tree.h>? Also check the answer to similar question on SO.
So far I've solved it like this: stackoverflow.com/questions/9614918/… Thank you!
19

LibXML2 library solved

SOLUTION!

if you have xcode 4.3.x in /Application

need ONLY add: "/usr/include/libxml2" without quote in Application TARGET -> Header search path.

for this -> double click on the line -> on little window click plus sign an write /usr/include/libxml2

nb - need also add libxml2.dylib to the framework. I use 2.2.7.3

hope help you

Comments

8

I solved the problem by setting the Header Search Path to:

${SDK_DIR}/usr/include/libxml2 

and Always Search User Paths to NO (which is strongly suggested anyway) This just in the target.

Comments

7

It appears in 4.3.1, you need to include the Header Search Paths in the Targets as well as the project. I'm not sure if this was an issue with moving from 4.2 to 4.3.1, but I just update to Lion and ran into the same issue.

1 Comment

Adding to the target is enought. What is the point of adding it to the project then anyway?
4

I ran into this again today, I would recommend you wrap the path in quotes:

"$(SDKROOT)/usr/include/libxml2" 

I wasted half an hour on this due to having spaces in my path.

Comments

3

The correct path is (for 'Header Search Path'):

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/include/libxml2/**

1 Comment

It's definitely an issue when updating to Xcode 4.3.1, as an app I had working just fine started failing. Adding this to the header search path IN ADDITION TO /usr/include/libxml2 (and checking recursive for both) seems to fix it.
3

I have the same problem.

I try set path( 'Header Search Path') to /usr/include/libxml2 ,build error!

I try set path( 'Header Search Path') to $(SDKROOT)/usr/include/libxml2 ,build error!

but I set path to

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/include/libxml2 

build succeeded!

Comments

3

Xcode 6:

Do the following:

1.0)Select "mainApp" Target : Go to settings ->In "Header Search Path"

1.1)Add this: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2.

2.0)Select "TestApp" Target : Go to settings ->In "Header Search Path"

2.1)Add this: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2.

Comments

2

2 solutions:

  1. header search path should be updated with SDK root as such: $(SDKROOT)/usr/include/libxml2
  2. Install command line tools for XCode 5 from terminal by entering: xcode-select --install XCode 4 should have the command line tools install option in preferences>downloads section.

I'd personally go with the second one.

Comments

0

I had to configure the other Linker Flags like this: for Debug and Release do Add Build Settings (lower right corner) and Add Conditional Settings. Then, select Any iOS Simulator SDK and insert the Setting -lxml2

Comments

0

In my case, the main difficulty was that the app is composed of two projects, with the second one having several targets. It took me a while to realise that the error was occurring in one of those targets and not in the target of the main project. Then I just had to add the (in)famous $(SDKROOT)/usr/include/libxml2 in the Header Search Paths of that particular target.

I am using Xcode Version 5.0.1

Comments

0

I already had the header search path and frame work but was getting this error. Forcefully quitting xcode and then restarting it worked for me (I was using xcode 7.2)

1 Comment

Although, question is old enough but may be the answer can help someone
0

In debug/release add the search path to Any Architecture | Any SDK That is click the + button near debug and add ${SDKROOT}/usr/include/libxml2 Similarly do the above for release also

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.