source code:

http://code.google.com/p/gdata-objectivec-client/

 

 

 

http://johntwang.com/blog/2009/06/08/how-to-use-google-apis-with-iphone-sdk/

 

 

 

Adding Google API support to your iPhone App could not be any easier. Google provides Objective-C APIs for:

Step 1

The first step, is to head on over to the Google Code website for the Objective-C Client,download and extract the zip file source code. Alternatively, you can get the latest and greatest version via Subversion using:

 svn checkout http://gdata-objectivec-client.googlecode.com/svn/trunk/gdata-objectivec-client-read-only

If you downloaded the zip file from the website, you’ll have version 1.7.0, and if you used the svn code you’ll have a -read-only folder.

Step 2

Open up the GData XCode Project from your downloaded folder as well as your iPhone App XCode project.

extracted

Step 3

Drag over the GData Sources Folder from the GData project to your iPhone App project and add it as reference. Don’t check the box for Copy items into destination group’s folder (if needed). You do not need to copy over all the files into your project. You can, but it’s not required.

to_drag

copy_reference

This will add a ton of files to your project. You may delete the APIs you are not planning on using, but make sure that the files GDataXMLNode.m andGDataXMLNode.h in the Common/Optional/XMLSupport group are not removed from your project as they are required for iPhone builds.

files

Step 4

Open up the build settings for your iPhone App project. Located and set the following settings.

  • Header Search Paths: /usr/include/libxml2
  • Other Linker Flags: -lxml2

For the Debug build configuration only, add the Other C Flags setting so that the library’s debug-only code is included:

  • Other C Flags: -DDEBUG=1

build

Step 5 (Optional for iPhone 3.0 Beta SDK)

If you downloaded the zip file version (1.7.0) of the API, you will also run into this error message when you attempt to first build your iPhone App project:

...Source/Networking/GDataHTTPFetcherLogging.m:224: error: 'NSTask' undeclared (first use in
...Source/Networking/GDataHTTPFetcherLogging.m:224: error: 'task' undeclared (first use in this
function)

Error Message

Apple has removed the NSTask from the Foundations Framework in the iPhone 3.0 SDK. In order to fix this, simply open up the GDataDefines.h file, find the developer section and add:

#define GDATA_SKIP_LOG_XMLFORMAT 1

gdefine

Note: This fix is only needed if you downloaded version 1.7.0 of the GData Objective-C API and are using iPhone 3.0 Beta SDK. If you downloaded the latest Subversion read-only trunk of the code or are using iPhone 2.2.1 SDK, you do not need to do this.

Step 6

At this point, your iPhone XCode project should build successfully and you can begin using the Google APIs by simply importing the appropriate header files. i.e.

#import "GDataAnalytics.h"

Step 7 (Optional if downloaded GData version 1.7.0 Zip file)

If you downloaded the zip file version (1.7.0) of the API, you will be missing the Analytics API. That has not yet been zipped up for the download. You may want to download those separately.

Additional Resources:

 

By admin-powenko

Dr. Powen Ko is a teacher and CEO on LoopTek LLC, and like to teaching. if you need to class, please let PowenKo know, he will love to service and sharing. LoopTek web site is www.looptek.com

Leave a Reply