# Using the Google APIs Client Library for Objective-C for REST (GTLR) Google APIs allow client software to access and manipulate data hosted by Google services. The Google APIs Objective-C Client Library for REST APIs is a Objective-C framework that enables developers for iOS, macOS, tvOS, and watchOS to easily write native applications using Google's JSON REST APIs. The framework handles * JSON parsing and generation * Networking * File uploading and downloading * Batch requests and responses * Service-specific protocols and query generation * Testing without network activity * HTTP logging ## Preparing to Use the Library ### Example Applications The Examples directory contains example applications showing typical interactions with Google services using the framework. The applications act as simple browsers for the data classes for each service. The WindowController source files of the samples were written with typical Cocoa idioms to serve as quick introductions to use of the APIs. The example applications run on macOS, but the library does not provide any user interface support apart from authentication, so use of the library APIs is the same for Mac and iOS applications. In order to use the example applications that require authentication, you can follow the same steps as for the [GTMAppAuth Examples](https://github.com/google/GTMAppAuth/tree/master/Examples/Example-macOS) The **client secret** can be blank/nil. Google APIs which do not require authentication may require an **API key**, also obtained from the [Developer Console](https://console.developers.google.com/). ### Adding the Library to a Project #### Integration via CocoaPods If you are building from CocoaPods, just use the pod provided, `GoogleAPIClientForREST`. The `Core` subspec includes the common parts of the library. There is also a subspec for each service API provided, such as Calendar and Drive. Your project can just depend on one or more service subspecs, and the core library files will be built as well. See the [podspec file](https://github.com/google/google-api-objectivec-client-for-rest/blob/main/GoogleAPIClientForREST.podspec) for the subspec names. For example, if you needed the _Drive_ apis, you'd just need to add: ``` pod 'GoogleAPIClientForREST/Drive' ``` To your `Podfile` and run `pod install`. If you are generating code for your own APIs, then add `pod 'GoogleAPIClientForREST/Core'` to get the supporting runtime and then manually add the generated sources to your Xcode project. #### Integration via Swift Package Manager (SwiftPM) Refer to the Xcode docs for how to add SwiftPM based dependences to the Xcode UI or via your `Package.swift` file. The `GoogleAPIClientForRESTCore` product includes the common parts of the library, and then there are specific products for each service API provide. Your project can use one or multiple services. See the [Package.swift](https://github.com/google/google-api-objectivec-client-for-rest/blob/main/Package.swift) for the different product names. For example, if you needed the _Drive_ apis, you just need to depend on the `GoogleAPIClientForREST_Drive` product. If you are generating code for your own APIs, then add `GoogleAPIClientForRESTCore` to get the supporting runtime and then manually add the generated sources to your Xcode project. ### `#import`s and `@import`s Since CocoaPods and SwiftPM use different models for how things are built, the module names for `@import` directives will be specific to each packaging system. However, if consuming this library via Objective-C, all the packages export their headers as _GoogleAPIClientForREST/HEADER.h_, so you can always `#import` them as a framework import and that will work with either packaging system, i.e. - `#import GTMSessionFetcher logging to > "/Users/username/Library/Developer/CoreSimulator/Devices/3B2F01FE-9D64-4C20/data/Containers/Data/Application/FB8E3483-23022D135FB4/GTMHTTPDebugLogs" The path (including the quotes) can be pasted into a terminal window to open the logs folder: ```shell open "/Users/username/Library/Developer/.../GTMHTTPDebugLogs" ``` The path to the logs folder can be specified with the `+setLoggingDirectory:` method. To view the most recently saved logs, use a web browser to open the symlink named `MyAppName_log_newest.html` (for whatever your application's name is) in the logging directory. For each executed query, when logging is enabled, the http log is also available as the property `ticket.objectFetcher.log` **_iOS Note:_** Logging support is stripped out in non-DEBUG builds by default. This can be overridden by explicitly setting `STRIP_GTM_FETCH_LOGGING=0` for the project. **_Tip:_** Providing a convenient way for your users to enable logging is often helpful in diagnosing problems when using the API. ## Questions and Comments **If you have any questions or comments** about the library or this documentation, please join the [discussion group](http://groups.google.com/group/google-api-objectivec-client).