My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes  
Changes to /wiki/BuildingTheLibrary.wiki
r710 vs. r711 Compare: vs.  Format:
Revision r711
Go to: 
Project members, sign in to write a code review
/wiki/BuildingTheLibrary.wiki   r710 /wiki/BuildingTheLibrary.wiki   r711
1 #summary Adding the Google Data API Objective-C Client Library to a Project 1 #summary Adding the Google Data API Objective-C Client Library to a Project
2 #labels Featured 2 #labels Featured
3 3
4 <wiki:toc max_depth="4" /> 4 <wiki:toc max_depth="4" />
5 5
6 = Adding the Google Data APIs to a Project = 6 = Adding the Google Data APIs to a Project =
7 7
8 The Google Data APIs Objective-C Client Library is provided as a built framework, suitable for inclusion in a Mac application bundle's Frameworks folder, and as a static library for iPhone applications. Alternatively, the sources may also be compiled directly into a Mac or an iPhone application. 8 The Google Data APIs Objective-C Client Library is provided as a built framework, suitable for inclusion in a Mac application bundle's Frameworks folder, and as a static library for iPhone applications. Alternatively, the sources may also be compiled directly into a Mac or an iPhone application.
9 9
10 == Checking Out Sources == 10 == Checking Out Sources ==
11 11
12 Check out the top-of-trunk sources using the command line sources shown [http://code.google.com/p/gdata-objectivec-client/source/checkout here]. 12 Check out the top-of-trunk sources using the command line sources shown [http://code.google.com/p/gdata-objectivec-client/source/checkout here].
13 13
14 == Linking to the Mac OS X Framework == 14 == Linking to the Mac OS X Framework ==
15 15
16 To add the framework to an Xcode project, drag GData.framework to the project's Linked Frameworks source group, then drag the GData framework from the Linked Frameworks group folder to the Link Binary With Library phase inside of the application target. 16 To add the framework to an Xcode project, drag GData.framework to the project's Linked Frameworks source group, then drag the GData framework from the Linked Frameworks group folder to the Link Binary With Library phase inside of the application target.
17 17
18 Source files referring to GData objects should include either the full GData headers as 18 Source files referring to GData objects should include either the full GData headers as
19 19
20 `#import "GData/GData.h"` 20 `#import "GData/GData.h"`
21 21
22 or the header for a specific service, such as 22 or the header for a specific service, such as
23 23
24 `#import "GData/GDataCalendar.h"` 24 `#import "GData/GDataCalendar.h"`
25 25
26 To facilitate debugging, you may choose to include the GData.xcodeproj project file directly in your application project as a cross-project reference. The example applications show how to include a reference to the GData framework project file in an Xcode project. 26 To facilitate debugging, you may choose to include the GData.xcodeproj project file directly in your application project as a cross-project reference. The example applications show how to include a reference to the GData framework project file in an Xcode project.
27 27
28 *_Tip_*: if Xcode's debugger is ignoring breakpoints set in the framework, turn off the "Load symbols lazily" option in Xcode's Debugging preferences. 28 *_Tip_*: if Xcode's debugger is ignoring breakpoints set in the framework, turn off the "Load symbols lazily" option in Xcode's Debugging preferences.
29 29
30 == Linking to the iPhone Static Library == 30 == Linking to the iPhone Static Library ==
31 31
32 _*Tip*: Developer hoishing has published helpful tips, including photographs, for building the static library in Xcode 4 in [http://hoishing.wordpress.com/2011/08/23/gdata-static-library-for-specific-api/ his blog]._ 32 _*Tip*: Developer hoishing has published helpful tips, including photographs, for building the static library in Xcode 4 in [http://hoishing.wordpress.com/2011/08/23/gdata-objective-c-client-setup-in-xcode-4/ his blog]._
33 33
34 The library project includes a target for building a static library for iPhone and iPod Touch apps; this avoids dragging individual library source files into the iPhone application's project. 34 The library project includes a target for building a static library for iPhone and iPod Touch apps; this avoids dragging individual library source files into the iPhone application's project.
35 35
36 To build with the static library, drag the GData project file itself into an iPhone project to make a cross-project reference, and add the GDataTouchStaticLib target as a dependency for building the app. 36 To build with the static library, drag the GData project file itself into an iPhone project to make a cross-project reference, and add the GDataTouchStaticLib target as a dependency for building the app.
37 37
38 Drag the static library target from under the GData.xcodeproj cross-project reference in the application project to the application target's "Link Binary With Libraries" build phase. 38 Drag the static library target from under the GData.xcodeproj cross-project reference in the application project to the application target's "Link Binary With Libraries" build phase.
39 39
40 Next, add the [http://developer.apple.com/mac/library/qa/qa2006/qa1490.html ObjC link option] to the application target's build settings, along with the libxml2 and [http://developer.apple.com/library/mac/#qa/qa2006/qa1490.html all_load] flags: 40 Next, add the [http://developer.apple.com/mac/library/qa/qa2006/qa1490.html ObjC link option] to the application target's build settings, along with the libxml2 and [http://developer.apple.com/library/mac/#qa/qa2006/qa1490.html all_load] flags:
41 41
42 Other Linker Flags: `-ObjC -lxml2 -all_load` 42 Other Linker Flags: `-ObjC -lxml2 -all_load`
43 43
44 Also add the compile flags described below in "Removing Unneeded Code". 44 Also add the compile flags described below in "Removing Unneeded Code".
45 45
46 The static library build creates a directory of header files (in its build products directory, `~/Library/Developer/Xcode/DerivedData`) that should be dragged into your application project. With the static library linked into your project, refer directly to the headers by omitting the framework name, like 46 The static library build creates a directory of header files (in its build products directory, `~/Library/Developer/Xcode/DerivedData`) that should be dragged into your application project. With the static library linked into your project, refer directly to the headers by omitting the framework name, like
47 47
48 `#import "GDataCalendar.h"` 48 `#import "GDataCalendar.h"`
49 49
50 *_Note:_* If you include the OAuth 2 sign-in classes in the library, your application will need to link to Security.framework and !SystemConfiguration.framework. To avoid including unneeded library code, see _Removing Unneeded Code_ below. 50 *_Note:_* If you include the OAuth 2 sign-in classes in the library, your application will need to link to Security.framework and !SystemConfiguration.framework. To avoid including unneeded library code, see _Removing Unneeded Code_ below.
51 51
52 == Compiling the Source Files Directly into a Mac or iPhone Application == 52 == Compiling the Source Files Directly into a Mac or iPhone Application ==
53 53
54 Rather than link to the GData framework, you can compile the GData library sources directly into your own project. To do this, drag the GData Sources source group from the GData Xcode project into your project's window (add by reference, not by copying the files.) 54 Rather than link to the GData framework, you can compile the GData library sources directly into your own project. To do this, drag the GData Sources source group from the GData Xcode project into your project's window (add by reference, not by copying the files.)
55 55
56 You can delete the references to the client services (Calendar, Contacts, Spreadsheet, and so on) that are not needed by your application, though they will not be compiled if you set the compiler flags described below in "Removing Unneeded Code." 56 You can delete the references to the client services (Calendar, Contacts, Spreadsheet, and so on) that are not needed by your application, though they will not be compiled if you set the compiler flags described below in "Removing Unneeded Code."
57 57
58 58
59 If you compile the project's source files directly into your own project file, set this build setting: 59 If you compile the project's source files directly into your own project file, set this build setting:
60 60
61 C Language Dialect: `C99 [-std=c99]` 61 C Language Dialect: `C99 [-std=c99]`
62 62
63 Search the build settings for "c99" to find the setting. If it's not present as a build option, and if a compile error requires c99, then set the equivalent user-defined setting: 63 Search the build settings for "c99" to find the setting. If it's not present as a build option, and if a compile error requires c99, then set the equivalent user-defined setting:
64 64
65 `GCC_C_LANGUAGE_STANDARD=c99` 65 `GCC_C_LANGUAGE_STANDARD=c99`
66 66
67 For just the Debug configuration of your target, add this compiler definition to ensure that the library's debug-only code is included: 67 For just the Debug configuration of your target, add this compiler definition to ensure that the library's debug-only code is included:
68 68
69 Other C Flags: `-DDEBUG=1` 69 Other C Flags: `-DDEBUG=1`
70 70
71 Or, if the Other C Flags setting is not available in your target's build options, set the equivalent user-defined setting: 71 Or, if the Other C Flags setting is not available in your target's build options, set the equivalent user-defined setting:
72 72
73 `OTHER_CFLAGS=-DDEBUG=1` 73 `OTHER_CFLAGS=-DDEBUG=1`
74 74
75 75
76 With the source files compiled directly in your project, refer directly to the headers by omitting the framework name, like 76 With the source files compiled directly in your project, refer directly to the headers by omitting the framework name, like
77 77
78 `#import "GDataCalendar.h"` 78 `#import "GDataCalendar.h"`
79 79
80 *_ARC Compatibility_* 80 *_ARC Compatibility_*
81 81
82 When the library source files are compiled directly into a project that uses ARC, then ARC must be disabled specifically for the library sources. 82 When the library source files are compiled directly into a project that uses ARC, then ARC must be disabled specifically for the library sources.
83 83
84 To disable ARC for source files in Xcode 4, select the project and the target in Xcode. Under the target "Build Phases" tab, expand the Compile Sources build phase, select the library source files, then press Enter to open an edit field, and type `-fno-objc-arc` as the compiler flag for those files. 84 To disable ARC for source files in Xcode 4, select the project and the target in Xcode. Under the target "Build Phases" tab, expand the Compile Sources build phase, select the library source files, then press Enter to open an edit field, and type `-fno-objc-arc` as the compiler flag for those files.
85 85
86 *_Notes for iPhone apps compiling the source files directly_* 86 *_Notes for iPhone apps compiling the source files directly_*
87 87
88 Be sure that the files GDataXMLNode.m and GDataXMLNode.h in the Common/Optional/XMLSupport group are included in your project. They are required for iPhone builds. 88 Be sure that the files GDataXMLNode.m and GDataXMLNode.h in the Common/Optional/XMLSupport group are included in your project. They are required for iPhone builds.
89 89
90 iPhone applications also need these build settings in the project or target: 90 iPhone applications also need these build settings in the project or target:
91 91
92 Header Search Paths: `/usr/include/libxml2` 92 Header Search Paths: `/usr/include/libxml2`
93 93
94 Other Linker Flags: `-lxml2` 94 Other Linker Flags: `-lxml2`
95 95
96 == Removing Unneeded Code == 96 == Removing Unneeded Code ==
97 97
98 However you build the library, it is worthwhile to remove code for the services that your application will not be using. To remove unneeded code, set these compile flags in the project or target build settings of the GData.xcodeproj project file. When compiling the sources directly into your application, set these flags in your project's settings. 98 However you build the library, it is worthwhile to remove code for the services that your application will not be using. To remove unneeded code, set these compile flags in the project or target build settings of the GData.xcodeproj project file. When compiling the sources directly into your application, set these flags in your project's settings.
99 99
100 The conditional flags in most source files of the library look something like this: 100 The conditional flags in most source files of the library look something like this:
101 {{{ 101 {{{
102 #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE 102 #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE
103 }}} 103 }}}
104 So in either the project's settings for compile flags or in your project's config file, set 104 So in either the project's settings for compile flags or in your project's config file, set
105 `GDATA_REQUIRE_SERVICE_INCLUDES` to 1, along with the services you are using. 105 `GDATA_REQUIRE_SERVICE_INCLUDES` to 1, along with the services you are using.
106 For example, 106 For example,
107 Other C Flags: `-DGDATA_REQUIRE_SERVICE_INCLUDES=1 -DGDATA_INCLUDE_CONTACTS_SERVICE=1` 107 Other C Flags: `-DGDATA_REQUIRE_SERVICE_INCLUDES=1 -DGDATA_INCLUDE_CONTACTS_SERVICE=1`
108 108
109 If your project compiles the OAuth 2 classes for authentication, also define the conditional `-DGTM_INCLUDE_OAUTH2=1` in Other C Flags. 109 If your project compiles the OAuth 2 classes for authentication, also define the conditional `-DGTM_INCLUDE_OAUTH2=1` in Other C Flags.
110 110
111 Do remember to set build settings so they apply to both Debug _and_ Release configurations. 111 Do remember to set build settings so they apply to both Debug _and_ Release configurations.
112 112
113 There is a conditional set in the static library target as a reminder to developers to define the needed services. For your project, replace or delete the definition 113 There is a conditional set in the static library target as a reminder to developers to define the needed services. For your project, replace or delete the definition
114 {{{ 114 {{{
115 -DGDATA_INCLUDE_nameServiceHere_SERVICE=1 115 -DGDATA_INCLUDE_nameServiceHere_SERVICE=1
116 }}} 116 }}}
117 in the Other C Flags section of the static library target's Release configuration. 117 in the Other C Flags section of the static library target's Release configuration.
Powered by Google Project Hosting