Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
I'm working through a Ray Wenderlich tutorial at the moment and it's going good. However, I don't understand why I had to add header paths and linker flags.

  1. Download the gdata-objective-c client library.
  2. Unzip the file, navigate to Source\XMLSupport, and drag the two files GDataXMLNode.h and GDataXMLNode.m into your project.
  3. In XCode, click Project\Edit Project Settings and make sure “All Configurations” are checked.
  4. Find the Search Paths\Header Search Paths setting and add /usr/include/libxml2 to the list.
  5. Finally, find the Linking\Other Linker Flags section and add -lxml2 to the list.
  6. Test out that everything is working by adding the following to the top of XMLTestAppDelegate.h:

What does step 4 and 5 actually do? If I'm linking to external resources, why do it this way? Why not drag them into the visible bundle in the folder structure?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
I haven't looked at this tutorial but steps 4, 5 are the "Xcode is a make file" route.

I agree that it's better to add the xml2.dylib to your frameworks section in your project than to add the -lxml2 linker flag. Both methods will work but adding the library to the frameworks section uses Xcode more the way it was intended to be used and you have the visible reminder that it's in there, can easily add/remove it to different targets, etc. In the end though it's personal preference.

Not sure about the header search path. If Xcode doesn't add that by itself then you need that to get access to the header files for this library.
 

grobbins

macrumors member
Dec 2, 2002
81
0
Xcode was designed to treat frameworks as first-class objects for building in its list of sources. But GDataXML relies on libxml2, which is a dynamic library but is not a framework. So the library instructions describe compiling and linking to libxml2 using the traditional method for linking to a standard system non-framework library and compiling against its headers.

When the GData library was developed years ago, Xcode did not offer good support for non-framework libraries in its sources list, though Xcode may have improved in that respect since then.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.