24

i am integrating twitter application in my application my application is created in xcode 4.2 using ARC when i implemented code for twitter from this code. it worked perfectly when i just download the project & run it. when i integrate this twitter sdk code in my xcode 4.2 based application it gave me error of 'libxml/xmlreader.h' file not found i have solved it just changing header file this way #include <libxml2/libxml/xmlreader.h> but after changing this previous error was solved but than i got new error 'libxml/xmlversion.h' file not found. i tried to change header of file xmlreader.h but this file is not editable i have changed permissions for this file, too. but it didn't work. in the format like this #include <libxml2/libxml/xmlreader.h> but it doesn't work.

please tell me how to solve this error.

i have seen several question in stack overflow for some that kind of question

but they didn't work for me in xcode 4.2. please guide me.

Community
  • 1
  • 1
Hrushikesh Betai
  • 2,227
  • 5
  • 33
  • 63
  • i thought that is ARC error so i have also disable ARC than tried but it didn't work. one more question some time my application receive memory warning in Enabled form of ARC also so than what should i do? – Hrushikesh Betai Jan 13 '12 at 12:42
  • re ARC issues that is a separate issue and should be a separate question – mmmmmm Jan 13 '12 at 12:55
  • What does the build show was used for CompileC ? – mmmmmm Jan 13 '12 at 13:03
  • do you asking for this `build options->complire for c/c++/objective c` in this i have used compiler `Apple LLVM compiler 3.0` – Hrushikesh Betai Jan 13 '12 at 13:10
  • No I am asking for the command that Xcode ran to compile the code – mmmmmm Jan 13 '12 at 13:11
  • sorry i don't know how to see this? can you be more specific. – Hrushikesh Betai Jan 13 '12 at 13:13
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/6691/discussion-between-hrushikesh-and-mark) – Hrushikesh Betai Jan 13 '12 at 13:14
  • I had this problem and realized that the -"- character at the beginning of the header search path was missing. After fixing ${SDK_DIR}" to "${SDK_DIR}" it worked. – kubilay Sep 13 '12 at 14:05
  • 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:34

9 Answers9

29

You need to put all the libxml headers on the include path. For Xcode do this by adding /usr/include/libxml2 to the header paths (that will pass -I/usr/include/libxml2 to the c compiler)

This is in the build settings tab in Search Paths -> Header Search Paths

enter image description here

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
27

Works for me. Remember to add the library in Link Binary en Build Phases Section of the target project. pic2 pic1

Dennso
  • 780
  • 7
  • 6
25

Go to Project -> Build Settings and search for "User Header Search Paths" key and add this value:

"${SDK_DIR}"/usr/include/libxml2

It works perfectly in my xcode 4.5 + iOS 6

  • 1
    This is also better than the other solutions because it correctly uses the include files in Xcode's SDK, rather than the system headers. – Mike Weller Jan 14 '13 at 10:28
3

If you're using CocoaPods and get this error, you'll have to fork the spec and the following lines to it:

s.libraries = 'xml2'
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }

You'll have to remove the Pod, then re-install it as well, with the podspec pointing to your fork. The reason why you have to fork the Pod is because the Target where you would normally change this is generated by CocoaPods when you perform pod install.

Note that if you have other libraries that the Pod depends on, include them on the s.libraries line.

Source for this fix in the CocoaPods issue "Pod Integration Issues"

louielouie
  • 14,881
  • 3
  • 26
  • 31
3

I had the same problem as you. For me the problem was that I setup "Header Search Path" in Project Build Settings, but my Target Build Settings overrided that setting. I fixed this by adding $(inherited) line to Target Build Settings Header Search Paths.

kolyuchiy
  • 5,465
  • 2
  • 23
  • 31
2

In your build settings, for the key "Header Search Paths", add "$(SDK_DIR)"/usr/include/libxml2

I got the same errors and come to here, then I find the answer in below url https://github.com/ZaBlanc/RaptureXML#adding-rapturexml-to-your-project

Hope this can help you, I've solved it now.

Senry
  • 260
  • 4
  • 15
0

Add header search path as $(SDKROOT)/usr/include/libxml2

0

Be sure to use the non-recursive option when you add the key "Header Search Paths."

/usr/include/libxml2 -- This is the non-recurisve option

/usr/include/libxml2\** -- This is the recursive option and WILL

0

In XCode 5:

  1. Add "${SDK_DIR}"/usr/include/libxml2 to your Header Search Paths
  2. Add libxml2.dylib in Build Phases
ZaBlanc
  • 4,679
  • 1
  • 35
  • 38