Adam Wulf

The personal site, tutorials, and projects of Adam Wulf

Adding the libXML framework to your iPhone App

March 11th, 2008 · 9 Comments

When working on my first iPhone app, I needed to import the libXML framework into my project. I took a look at a sample app that used the libXML framework, and made sure that the framework list in my project matched the one in the sample project – but for some reason my project wouldn’t compile. It kept complaining that it couldn’t find a libXML header file or some such, and so finally i turned to The Google, and found the answer. I’m sure this stuff is a no-brainer for more experienced Cocoa / iPhone developers, but since I’m neither yet, I thought this was a bit trickier than I expected.

For extra clarity, I’m going to do a simple step by step to show how to get everything working in your project, if you’re having a similar problem:

1. Add the libXML framework to your project in XCode

The proper framework is located in: /Developer/Platforms/Aspen.platform/Developer/SDKs/Aspen1.2.sdk/usr/lib

2. Verify the libXML framework is properly added. This is where I got stumped, because my framework was added by my project wasn’t compiling! It still couldn’t find the proper header files for libXML, even though it was listed as a framework right here!

3. The not-so-obvious step is to add the libXML header files to the header search path in the build properties. To do this, expand the Targets node of your project, and right click your project target file and Get Info. Then add “/usr/include/libxml2″ to the header search path in target build settings.

Now compile, and everything should be compiling just fine! You can download the final LibXMLSample project here.

Tags: iphone · programming

9 responses so far ↓

  • 1 Buck Wilson // Mar 11, 2008 at 6:31 pm

    Hahaha, The Google.

  • 2 Jay // Aug 24, 2010 at 9:19 pm

    Yep almost 3 years later…

    Just wanted to say I was scouring “The Google” and found your tutorial. You wouldn’t BELIEVE how hard it is to find a spoon-fed tutorial like this for newbies such as myself.

    Many thanks!

  • 3 Lele // Sep 25, 2010 at 1:20 pm

    Thanks a lot, i find the solution for my problem with libxml2 :)

  • 4 links for 2010-11-07 | Alones world // Nov 7, 2010 at 9:04 pm

    [...] Adding the libXML framework to your iPhone App | Wulf (tags: libmxl2) [...]

  • 5 Josh Holat // Dec 1, 2010 at 12:22 am

    This worked. Thanks so much!

  • 6 viraj // Jan 3, 2011 at 5:23 am

    I was looking for this solution for days. Google, forums, blogs so many places I have searched for a solution. none of them really worked.

    You are the best. This is working perfectly. Thanks
    Adam.

  • 7 Slava Garmash // Jan 22, 2011 at 6:16 pm

    When I deleted Xcode 3 and installed Xcode 4 then /usr/include/libxml2 was not available anymore.

    I found it here:
    /Xcode4/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/usr/include/libxml2

  • 8 Rob // Mar 15, 2011 at 9:46 pm

    use this

    ${SDK_DIR}/usr/include/libxml2

    for any version of xcode, including xcode 4

  • 9 K-Res // May 18, 2011 at 4:56 am

    Thanks for the tip!Really helped me out.

Leave a Comment or