本文介绍了未找到GTMSessionFetcher.h文件将应用升级到最新的google-api-objectivec-client的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS应用中实现了对Google云端硬盘的访问。自2014年年中以来,这一功能一直是该应用的一项主动功能,并且在iOS 6,7& 8.我正在检查我的项目是否与iOS 9兼容。



我已经下载了最新的 google-api-objectivec-client 以确保我的项目保持最新。



我重做了标准Google实现......详见,并在本文末尾处提供。

问题:当我尝试构建任何版本时,收到错误 GTMSessionFetcher.h file not found。



我确定我已经按照以下步骤在Google网页上正确实施了API。



我查看了旧版本的代码,但不幸的是我没有备份Google SDK,因此无法轻易说出发生了什么变化。



似乎源于此.. 。 GTMOAuth2Authentication.h ...

  #if GTM_USE_SESSIO N_FETCHER 
#进口 GTMSessionFetcher.h
的#else
#进口 GTMHTTPFetcher.h
#ENDIF // GTM_USE_SESSION_FETCHER

我不明白 GTM_USE_SESSION_FETCHER 是如何设置的,为什么在这种情况下它是真的。



任何建议都非常感谢。






Google Drive API实施对于iOS
$ b

注意:步骤1和步骤2 2完成没有问题。



第3步:准备项目


  1. 在Xcode中,创建一个包含示例应用程序的新项目:


    • 单击文件>新建>项目,选择单一视图应用程序模板,然后单击下一步。

    • 填写产品名称,组织名称和公司标识符。确保选择Objective-C作为语言,然后单击下一步。

    • 选择项目的目标目录,然后单击创建。


  2. 通过从 Source 目录中拖动 GTL.xcodeproj 添加客户端库上面的客户端库下载文件夹放到XCode项目中。
  3. 在XCode项目导航器中,选择您创建的项目以显示项目设置。

  4. 在项目设置中选择Build Phases选项卡,然后修改 Link Binary with Libraries 列表以包括:


    • libGTLTouchStaticLib.a 来自GTL项目。

    • Security.framework 和 SystemConfiguration.framework 。


  5. 选择项目设置中的Build Settings选项卡并修改以下两个构建设置:


    • 将 -ObjC -all_load 添加到链接>其他链接器标志setti NG。编辑这些字段的好方法是单击字段名称选择它,然后单击Enter输入设置。

    • 将客户端库头添加到应用程序项目中,方法是添加使用递归选项将客户端库的源目录移至搜索路径>用户头搜索路径部分。您可以选择递归选项,方法是在路径中添加**或双击输入的路径并在出现的对话框中选择递归。
      要在基于Unix的系统中查找此目录的绝对路径,请在终端窗口中导航到步骤2中下载客户端库的目录,cd进入源目录,然后键入pwd命令。 li>

  6. 从客户端库的 Source / OAuth2拖放 GTMOAuth2ViewTouch.xib / Touch 文件夹放入应用程序的支持文件文件夹中。
  7. 通过拖动<$来自客户端库的源/服务/驱动器/生成的 GTLDrive.h 和 GTLDrive_Sources.m code>文件夹直接传递给应用程序项目。
  8. href =https://stackoverflow.com/users/4151216/rivero> Rivero 为我指出了正确的方向......



    感谢为他的答案。



    适用于iOS 6,7,8和; 9 ...



    乱砍以下...




    GTMOAuth2Authentication.h (OAuth目录)和<$>中<$> 第1步 c $ c> GTLService.h (对象目录)



    找到这个代码块...

     的#if(TARGET_OS_IPHONE&安培;!&安培;定义(MAC_OS_X_VERSION_10_11)及;&安培; MAC_OS_X_VERSION_MAX_ALLOWED> = MAC_OS_X_VERSION_10_11)\ 
    || (TARGET_OS_IPHONE&&& amp;& amp;& amp;& amp; amp; __IPHONE_OS_VERSION_MAX_ALLOWED> = __IPHONE_9_0)
    #ifndef GTM_USE_SESSION_FETCHER
    #define GTM_USE_SESSION_FETCHER 1
    #endif
    #endif

    ...并更改

      #define GTM_USE_SESSION_FETCHER 1 

    ...至

     的#define GTM_USE_SESSION_FETCHER 0 






    第二步 $ b GTMGatherInputStream.m (HTTPFetcher目录)

    ...更改

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

    ...至

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






    第3步



    在 GTMHTTPFetcherLogging.m (HTTPFetcher目录)中



    ...变化

     的NSString * escapedResponseFile = [responseDataFileName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 

    ...至

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






    第4步



    在Apple LLVM 7.0中的 GTL 项目设置中警告 - 所有语言



    ...更改



    弃用函数= YES



    ...至



    弃用的函数= NO





    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.
    解决方案

    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


    这篇关于未找到GTMSessionFetcher.h文件将应用升级到最新的google-api-objectivec-client的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 00:47