Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GTMSessionFetcher.h file not found upgrading app to latest google-api-objectivec-client

I implement access to Google Drive in my iOS app. This has been an active feature in the app since middle of 2014 and functions properly under iOS 6, 7 & 8. I am currently checking my project for compatibility with iOS 9.

I've downloaded the latest google-api-objectivec-client to ensure my project remains up to date.

I redid the standard Google implementation... as detailed in this page and included for completeness at the end of this post.

Problem: When I attempt to build in any of my releases I receive the error "GTMSessionFetcher.h file not found".

I'm certain I've implemented the API properly as per the steps below / on the Google web page.

I've looked through older versions of my code but unfortunately I did not back up the Google SDK, so cannot easily tell what has changed.

It seems to stem from this... within GTMOAuth2Authentication.h...

#if GTM_USE_SESSION_FETCHER
  #import "GTMSessionFetcher.h"
#else
  #import "GTMHTTPFetcher.h"
#endif  // GTM_USE_SESSION_FETCHER

I dont understand how GTM_USE_SESSION_FETCHER is set and why it would be true in this instance.

Any advice greatly appreciated.


Google Drive API Implementation for iOS

Note: Steps 1 & 2 complete without issue.

Step 3: Prepare the project

  1. In Xcode, create a new project to contain the sample app:
    • Click File > New > Project, select the Single View Application template, and click Next.
    • Fill in the Product Name, Organization Name, and Company Identifier. Make sure to select Objective-C as the Language, and then click Next.
    • Select a destination directory for the project and click Create.
  2. Add the client library by dragging GTL.xcodeproj from the Source directory of the client library download folder above into the XCode project.
  3. In the XCode Project Navigator, select the project you created to reveal the project settings.
  4. Select the Build Phases tab in the project settings and modify the Link Binary with Libraries list to include:
    • libGTLTouchStaticLib.a from the GTL project.
    • Security.framework and SystemConfiguration.framework.
  5. Select the Build Settings tab in the project settings and modify the following two build settings:
    • Add -ObjC -all_load to the Linking > Other Linker Flags setting. A good way to edit these fields is to click once on the field name to select it, then click Enter to input the setting.
    • Add the client library headers to the application project by adding the Source directory of the client library to the Search Paths > User headers search path section with the recursive option. You can select the recursive option either by appending ** to the path or by double-clicking the entered path and selecting recursive in the dialog that appears. To find the absolute path to this directory in a Unix-based system, navigate a terminal window to the directory where you downloaded the client library in Step 2, cd into the Source directory, and type the pwd command.
  6. Drag GTMOAuth2ViewTouch.xib from client library's Source/OAuth2/Touch folder into the app's Supporting Files folder.
  7. Add the Drive API service by dragging GTLDrive.h and GTLDrive_Sources.m from the client library's Source/Services/Drive/Generated folder directly to the application project.
like image 657
andrewbuilder Avatar asked Dec 10 '22 20:12

andrewbuilder


2 Answers

Thanks initially to Rivero for pointing me in the right direction...

Thanks to Peter for his answers to this question.

Building for iOS 6, 7, 8 & 9...

Hacked the following...


STEP 1

In GTMOAuth2Authentication.h (OAuth directory) and in GTLService.h (Objects directory)

find this code block...

#if (!TARGET_OS_IPHONE && defined(MAC_OS_X_VERSION_10_11) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11) \
  || (TARGET_OS_IPHONE && defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0)
  #ifndef GTM_USE_SESSION_FETCHER
    #define GTM_USE_SESSION_FETCHER 1
  #endif
#endif

... and change

#define GTM_USE_SESSION_FETCHER 1

... to

#define GTM_USE_SESSION_FETCHER 0

STEP 2

In GTMGatherInputStream.m (HTTPFetcher directory)

... change

return [[[self alloc] initWithArray:dataArray] autorelease];

... to

return [[(GTMGatherInputStream*)[self alloc] initWithArray:dataArray] autorelease];

STEP 3

In GTMHTTPFetcherLogging.m (HTTPFetcher directory)

... change

NSString *escapedResponseFile = [responseDataFileName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

... to

NSString *escapedResponseFile = [responseDataFileName stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

STEP 4

In GTL project settings, under Apple LLVM 7.0 Warnings - All Languages

... change

Deprecated Functions = YES

... to

Deprecated Functions = NO


like image 149
andrewbuilder Avatar answered Dec 29 '22 00:12

andrewbuilder


@andrewbuilder's solution works.

If your target is IOS 8, just change

#define GTM_USE_SESSION_FETCHER 1

to

#define GTM_USE_SESSION_FETCHER 0

in both GTMOAuth2Authentication.h and GTLService.h files.

If your target is IOS 9, you need to replace the GTMHTTPFetcher file with GTMSessionFetcher file (https://code.google.com/p/gtm-session-fetcher/).

Reference: https://github.com/google/google-api-objectivec-client/issues/88

like image 33
Yuchao Zhou Avatar answered Dec 28 '22 23:12

Yuchao Zhou