Kelvin's Blog
Life is a program you write everyday ~
GData Objective-C Client Setup in XCode 4
Posted by on 23 August 2011
My previous post suggested a simple way for deploying GData Objective-C client in Xcode 4, with a trade-off of using big static library image file (19MB).
By following the official compiling procedures, you may specify which API(s) to compile, and target for specific architecture (device or simulator). Thus the output image file will be significantly smaller (~3MB). However, its not easy to follow by just reading the text description in Google Code. So I prepared a step-by-step tutorial for its setup procedures, hope it helps
- Download the GData sources and drag the GData.xcodeproj from Finder into your project source tree.
- Add a new target dependency: Click your target -> Build Phases -> Target Dependencies -> the + button
- Choose GDataTouchStaticLib and click Add
- In your project target -> Build Phases -> Link Binary With Libraries, add the libGDataTouchStaticLib.a library under the Workspace folder. Its in red after adding, because it will be the build output of the previous step, that is not existed yet.
- Also add the following frameworks at the same place, they are needed by GData.
- Security.framework
- SystemConfiguration.framework
- In Build Settings, add the following entries under “Other Linker Flags”
- -ObjC
- -lxml2
- -all_load
- Also in Build Settings, set /usr/include/libxml2 under “Header Search Paths”
- Remove unnecessary APIs:
For instance, if I want Calendar API only, select the GDataTouchStaticLib target of your GData project cross reference. Add the following 2 entries in “Other C Flags” for both Debug and Release settings: - -DGDATA_REQUIRE_SERVICE_INCLUDES=1
- -DGDATA_INCLUDE_CALENDAR_SERVICE=1
- Note that -DGDATA_REQUIRE_SERVICE_INCLUDES=1 is compulsory (and already added in Release settings), while the others depend on what APIs you want. Say if you want Contacts API, you got to add
-DGDATA_INCLUDE_CONTACTS_SERVICE=1
and so on..
- Build your project (⌘B), get your build product by opening Organizer -> Projects,then show your derived data in Finder by clicking the little arrow.
- In your derived data directory, browse to Build/Products/Debug-iphonesimulator, then drag the Headers directory to your source tree. (just link the header files is fine, thanks Fistman for correction)

- Thats all! To use the GData classes, just import the following header file and start coding ~
#import "GData.h"
Hope this tutorial helps, happy coding :)
Advertisement









Pingback: GData Static Library for Specific API « Kelvin's Blog
Thank you thank you thank you!!!
ps.: Thank you!
Very useful! Thank you
Is there a way to avoid copying the headers directory?
Hi Fistman, you can just link the headers instead of copying them, just make sure you won’t delete them accidentally in any build cleaning process.
Adding ${BUILT_PRODUCTS_DIR}/Headers as a Header Search Path worked better for me.
The dependency you create makes sure the headers are always available (and fresh!) and there’s no need to bother your source control system with extra files you don’t care about.
Yes, you right. The dependency already made sure the availability of those header files. Thanks Fistman
you are awesome !!! Thank you so much !!
hi thanks a lot, I followed the procedure correct, but finally I build the project it says “Build Failed” but Xcode does not provide any build errors. any ideas????
Hi, I have now a problem.. When I build my project, an error say “GDara.h: No such file or directory”.. I really don’t know how to solve that.. Can someone help me ?
Thanks !
GData.h*
Pingback: Uploading to YouTube from iOS « code.with.me
Thank you! This saved me hours of configuration. Also, I’d heed the advice of Fistman by “Adding ${BUILT_PRODUCTS_DIR}/Headers as a Header Search Path”. Great tip and great post!! Much thanks
Have followed the exact instruction … but still got “No such file or directory” error.
u r so kind!
so helpful!!!! thx!!!
I have successfully imported the GData library in, thanks for your post, however I’m getting an issue, specifically with the GDataObject.h file, saying that “ARC forbids Objective-C objects in structs or unions”, and “The current deployment target does not support automated __weak references.
I am using Automatic Reference Counting in my project, and I can see that the GData library does not. I have read that you should be able to mix the two, as a lot of the standard Apple libraries are written without ARC, but the compiler that compiles my project is looking at the imported GData headers and throwing these errors.
I could turn off ARC for my project and rewrite the classes with the appropriate memory management, but I would really rather not! Have you come across this, and do you know of any way I can get around this problem? I find it strange that I can’t find any information on the web regarding other people with this issue, makes me think I am doing something wrong!
I appreciate you taking the time to read this.
Hi Ben,
I have an idea. What about start a new Xcode project (ARC disabled) to build a GData static library that you want, then employ this static library in your current project (ARC enabled)?
I described the static library building procedures in my other post:
https://hoishing.wordpress.com/2011/08/23/gdata-static-library-for-specific-api/
Hope it helps.
Hey Kelvin,
Thanks for your quick reply. I tried building a static library as you suggested, however I still get the same issue. The problem is that because I need to include the header files in my project, it causes ARC to throw the same errors around the GDataObject.h file. Do you know if it is possible to create a .framework library from the GData source? I wonder if that would fix the problem. Otherwise I will fall back to turning ARC off.
Cheers,
Ben.
Thanks for the tutorial. You have 2 separate projects here. One is GdataDemo and another is TestGData. As I was following your tutorial ( which BTW is great ) , I got confused because of 2 separate project names. Is this on purpose. Are you using one project to build stuff and another one to include the libraries?
Hi tdhaayushverma,
I guess you are asking why “GDataDemo” will include another “GData” project in it. The GData project is used for generating the GData static library, and this static library will be used in the GDataDemo project. You may find more details about this arrangement by searching “build phases” and “project dependency”
Thanks for sharing this, saved some valuable time. However, I’m getting the same error as “undercore” i.e. GData.h file not found. Can anyone please help me resolve this error? I’m developing using iOS 5 API’s.
– Vipul
works great! thanks for putting this together
not all header files are, genereted “GData.h” is missing for me too
After following the above steps, i ended with following Error. Can you please help me.
Undefined symbols for architecture i386:
“_OBJC_CLASS_$_GDataServiceGoogleContact”, referenced from:
objc-class-ref in IBCDetailViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Pingback: google doc iphone api « kosuel
Alleluia! Thanks for that, man! Very helpful!
Hi I have an issue which I posted on StackOverflow. Any chance you could take a look?
http://stackoverflow.com/questions/8972875/ios-iphone-ipad-project-with-gdata-static-library-libgdatatouchstaticlib-a-f
Hey,
I’m running an iPhone project with a deployment target of iOS 5.0 in XCode 4, i’ve followed your guide and am getting the following errors:
GTMHTTPFetcherLogging.m
/Users/absolutehype/Documents/………../Libraries/gdata-objectivec-client-read-only/Source/HTTPFetcher/GTMHTTPFetcherLogging.m
- (void)inputStream:(GTMReadMonitorInputStream *)stream
Category is implementing a method which will also be implemented by its primary class
+ (BOOL)fileOrDirExistsAtPath:(NSString *)path {
Category is implementing a method which will also be implemented by its primary class
Any ideas?
Saw this issue logged on Google Code – http://code.google.com/p/gdata-objectivec-client/issues/detail?id=97#c0 may be related?
I apologise, i’m still relatively new to linking libraries – it messes with my head
and thanks by the way. This really is the most concise post i’ve seen on using the gdata libs with obj-c!
Pingback: after setup GData ios client in xcode4, can’t use OAuth | appsgoogleplus.com