Search code examples
iosobjective-cxcodegdatagdata-objectivec-client

How to include GData in project?


I'm trying to include GData framework in my project for hours now and I'm completely lost. I'm trying to follow instructions on gdata-objectivec-client's page (https://code.google.com/p/gdata-objectivec-client/), but they're very outdated.

If I try to link static library (using instructions from this site, which is referenced in installation guide -> https://hoishing.wordpress.com/2011/08/23/gdata-objective-c-client-setup-in-xcode-4/) In the end I get those errors:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_GDataServiceGoogleSpreadsheet", referenced from:
  objc-class-ref in ViewController.o
  "_kGDataGoogleSpreadsheetsPrivateFullFeed", referenced from:
  -[ViewController fetchFeedOfSpreadsheets] in ViewController.o
ld: symbol(s) not found for architecture arm64

What I found out is that they might be caused by gdata-objectivec-client being not ARC compatible. It could be fixed by adding "-fno-objc-arc" flags in Build Phases -> Compile Sources if there have been gdata's files, but since I'm cross-referencing project there are not there.

Other method is compiling source files directly, but the method provided is very outdated. First step is to drag "Source" group from GData project to my project and that is not possible in Xcode for a long time now. For what I know, today I have to open project files in Finder and drag them to my project, but that way I'm importing whole project, not only source files. Also if I do it that way folder in Project Explorer is blue and I can't import any of GData's header files.

I'm out of ideas what should I do next to make this work with Xcode 6 and iOS8, any help will be very appreciated.


Solution

  • OK, it turns out that as of today, that is not a simple matter. I had absolute no luck with tutorials provided in Google's documentation (be it a static library or compiling from source). I also tried cocoa pods by making a Podfile and requesting a pod 'GData', which also is broken. One of the dependencies is doubled and makes a lot of "duplicate symbol" errors. But it turns out that it can be quite easily fixed and I finally was able to use GData Objective-C client with iOS8 and Xcode 6.3.

    Here's what you have to do (I assume that you already have working cocoa pods installation on your machine):

    pod init

    In console, navigate to root of your project and type 'pod init'

    Insert this in a podfile:

    pod 'GData', :podspec => 'GData.podspec.json'
    

    Create custom podspec file with removed duplicate dependency from official podspec.

    We have to delete troublesome "GTMHTTPFetcher" from dependencies. Create a file named GData.podspec.json in root catalog of your project. Fill it with content so it looks like that:

    {
      "name": "GData",
      "version": "1.12.0",
      "license": {
        "type": "Apache License, Version 2.0",
        "file": "COPYING.txt"
      },
      "summary": "The Google data APIs provide a simple protocol for reading and writing data on the web. Many Google services provide a Google data API.",
      "homepage": "https://code.google.com/p/gdata-objectivec-client",
      "authors": {
        "The Google Data APIs team": "https://code.google.com/p/gdata-objectivec-client"
      },
      "source": {
        "svn": "http://gdata-objectivec-client.googlecode.com/svn/trunk"
      },
      "dependencies": {
        "gtm-oauth2": [
    
        ]
      },
      "requires_arc": false,
      "subspecs": [
        {
          "name": "Core",
          "source_files": [
            "Source/ACL/*.{h,m}",
            "Source/BaseClasses/*.{h,m}",
            "Source/Elements/*.{h,m}",
            "Source/Geo/*.{h,m}",
            "Source/Introspection/*.{h,m}",
            "Source/Media/*.{h,m}",
            "Source/Networking/*.{h,m}",
            "Source/XMLSupport/*.{h,m}",
            "Source/*.{h,m}",
            "Source/Clients/**/*.{h,m}"
          ],
          "libraries": "xml2",
          "xcconfig": {
            "HEADER_SEARCH_PATHS": "\"$(SDKROOT)/usr/include/libxml2\""
          }
        },
        {
          "name": "XMLNode",
          "source_files": "Source/XMLSupport/*.{h,m}",
          "libraries": "xml2",
          "xcconfig": {
            "HEADER_SEARCH_PATHS": "\"$(SDKROOT)/usr/include/libxml2\""
          }
        }
      ]
    }
    

    Update "version" in GData.podspec.json

    Visit https://cocoapods.org/pods/GData and look up the latest version of GData at the top of the page. Replace "version" in the GData.podspec.json with that version number.

    Execute 'pod install'

    And you're done! Now the GData libraries will finally compile and you can start using this. This fix may not be big, but it really took me hours to find out what the problem was and how to eliminate it. I hope that it will prove useful to someone else.