Search code examples
iphoneiosgdata

ios iPhone / iPad - Project with GData static library libGDataTouchStaticLib.a fails on build (duplicate symbol)


I am trying to build an App using the GData static library libGDataTouchStaticLib.a I have made all the appropriate linkings in my project settings and have copied GDataXMLNode.h and GDataXMLNode.m to my project.

I am receiving the error below. Can someone help me understand what this is?

ld: duplicate symbol _kGDataXMLXPathDefaultNamespacePrefix in /Users/myUser/Library/Developer/Xcode/DerivedData/GData-edmqtrniowvhfjgfgngtlfxttvri/Build/Products/Debug-iphoneos/libGDataTouchStaticLib.a(GDataXMLNode.o) and /Users/myUser/Library/Developer/Xcode/DerivedData/MyApp-grzimbvctfmwhmdluxbuxmskcvzy/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/GDataXMLNode.o for architecture armv7 Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1


Solution

  • You shouldn't have to copy in GDataXMLNode.h and GDataXMLNode.m to your project. I believe the reason you are getting the duplicate symbol error is because the libGDataTouchStaticLib.a library already contains the compiled GDataXMLNode.m class.

    I am currently using the GData library in a project I am working on, and got it set up by using these instructions: http://hoishing.wordpress.com/2011/08/23/gdata-objective-c-client-setup-in-xcode-4/, so this answer assumes that you have the same setup. However I have used a slightly different way of importing the headers that was suggested by one of the comments on the above blog.

    In your Xcode project remove the GDataXMLNode.h and GDataXMLNode.m files, and make sure that the GData.xcodeproj project is linked into your project the same way as in the above blog, but do not drag the headers directory to your source tree. Add these arguments to the Debug and Release Header Search Paths of your current target instead:

    /usr/include/libxml2
    ${BUILT_PRODUCTS_DIR}/Headers
    

    You can find this under the Build Settings tab of your target. The second argument will import all the GData headers into your project if you have set up the GData.xcodeproj file correctly. Once you have done this you should be able to import the various GData classes including GDataXMLNode.h class wherever you need it by typing this at the top of the appropriate class:

    #import "GDataXMLNode.h"
    

    Much credit goes to Kelvin's blog for his great tutorial. Hope that helps!