+5  A: 

Follow the directions here, under "Setting up your project file."


Also see the OP's answer.

Matt Ball
Don't do what that says when it asks you to add "/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/include/libxml2" to the Header Search Path. Add "/usr/include/libxml2 instead. That makes your project independent of specific SDKs.
cdespinosa
That works just so long as there's actually a symlink to it in `/usr/include`. I haven't tried installing libxml2 so I can't confirm default behavior. But yes, it's much better to link it that way.
Matt Ball
When developping under XCode, GCC uses the -isysroot option that relocates the root of the SDK. If you add /usr/include/libxml2 in the header search paths, it will be translated at compilation time to the usr/include/libxml2 folder INSIDE the current SDK.
Laurent Etiemble
+3  A: 

You also need to add /usr/include/libxml2 to your include path.

Michael Krelin - hacker
A: 

Form the link of @Matt Ball,

I found following helpful to me.

You need to add libxml2.dylib to your project (don't put it in the Frameworks section). On the Mac, you'll find it at /usr/lib/libxml2.dylib and for the iPhone, you'll want the /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/lib/libxml2.dylib version.

Since libxml2 is a .dylib (not a nice friendly .framework) we still have one more thing to do. Go to the Project build settings (Project->Edit Project Settings->Build) and find the "Search Paths". In "Header Search Paths" add the following path on the Mac:

/usr/include/libxml2

sugar
+1  A: 

I had this problem when I reopened a project (which was developed on XCode 3.something on Leopard) after upgrading to Snow Leopard and XCode 3.2. Curious enough, it only affected some kinds of builds (emulator builds went fine, device ones gave me the error). And I have libxml2 at /usr/include, and it indeed contains libxml/tree.h.

Even the magic "Clean" did not work, but "Empty Caches..." under the "XCode" menu (between the Apple logo and File) did the trick (was that menu there in previous versions?). Beats me the reason, but after a clean there were no more complaints regarding libxml/tree.h

chester
A: 

i got the same error but wat ever the above solutions doesn't worked out for mine..... is thr any other way to resolve.....

nikesh
+1  A: 

Another solution. do all the steps in header search path etc. and make sure your selected configuration in project in Project settings is the correct one. When you double click on project build settings ,you may be changing in Distribution settings, But you are trying to add header search path in "Distribution" settings. So make sure you are in correct settings. or choose all settings

Sijo
A: 

Thank you sugar..this really helped me out to solve my problem..

Gaurav aka sparsh