类'GTMHTTPUploadFetcher'的重复接口定义 [英] Duplicate interface definition for class 'GTMHTTPUploadFetcher'

查看:226
本文介绍了类'GTMHTTPUploadFetcher'的重复接口定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算在Swift项目中使用 Google Drive API 。我试图通过CocoaPods添加Drive SDK(v0.39.0)。下面是我的Podfile。

 平台:ios,'8.0'
use_frameworks!

pod'Google-API-Client / Drive'

我拥有添加了 use_frameworks!标志,以便CocoaPods可以将Objective-C窗格转换为Swift框架而不是静态库。



Pod安装成功。但是,当我构建项目时,出现以下错误。
$ b

类GTMHTTPUploadFetcher的重复接口定义



删除DerivedData文件夹并清理项目不起作用。

我也试过不添加 use_frameworks! / code>然后通过桥接标头方式添加库。这没有问题。事情是所有我的其他依赖与它打开工作。不幸的是,CocoaPods
$ b

有没有解决此问题的解决方法?






如Google的文档所述,Google工程师们应该监控标记为google-drive-sdk的问题,所以我希望至少他们能够看到这个问题并尽快解决。

解决方案

我遇到了同样的问题。我的解决方案是不使用CocoaPods安装适用于iOS的Google API Client,因为我使用的是基于Swift的窗格,因此我无法删除 use_frameworks!尝试解决重复的头问题。



我按照 https://developers.google.com/drive/ios/quickstart?ver=swift 步骤2,3和4.我按照说明将它们应用于现有的工作区,而不是创建新的工作区。



请注意,我必须调整用户标题搜索路径中的路径以匹配我实际从Google复制源代码的位置。



我正在复制说明


第2步:下载Google客户端库



运行以下命令以使用git下载库:


  • git clone https ://github.com/google/google-api-objectivec-client.git

  • git clone https:// github。 com / google / gtm-oauth2.git

  • git clone https://github.com/google/gtm-session-fetcher .git

  • git clone https://github.com/stig/json-framework.git -b v2.3
  • code>
  • cp -R gtm-oauth2 /源google-api-objectivec-client / Source / OAuth2 li>
  • cp -R json-framework /类google-api-objectivec-client / Source / JSON



第三步:准备工作区



打开Xcode并创建一个名为快速开始。
使用File> Add Files toQuickstart...,将以下项目添加到您在上一步中克隆的库中: b $ b

  • google-api-objectivec-client / Source / GTL.xcodeproj
  • gtm-session-fetcher / Source / GTMSessionFetcher.xcodeproj


    选择GTMSessionFetcher项目并进行以下更改:


    • 添加iOS类型的新目标>框架&库> Cocoa Touch静态库并将其命名为GTMSessionFetcherLib。
    • 将项目的GTMSessionFetcher组中的所有.m文件添加到目标的Build Phases> Compile Sources部分。



    • 选择GTL项目的GTLTouchStaticLib目标并进行以下更改:


      • 将库GTMSessionFetcher / libGTMSessionFetcherLib.a添加到Build Phases> Link Binary with Libraries。

      • 将绝对路径添加到gtm-session-fetcher / Source /设置>用户标题搜索路径。

      • 添加标志GTM_USE_SESSION_FETCHER = 1到构建设置>预处理器宏。

      • 删除GTL项目的GTLFramework target。

      • 在项目导航器中,删除GTL项目的GTL Source> Common> HTTPFetcher组。



      • 第4步:准备项目


        • 创建一个新的iOS> Ap plication>单一视图名为QuickstartApp的应用程序项目。将语言设置为Swift,并在保存项目时将Add to和Group字段设置为Quickstart。
        • 将以下框架和库添加到项目的Build Phases> Link Binary with Libraries部分:
          libGTLTouchStaticLib.a


          • Security.framework

          • SystemConfiguration.framework


          • 更改以下构建设置:

          • 将其添加到其他链接器标记。 $ b
          • 将以下目录的绝对路径添加到用户标题搜索路径:


            • gtm-session-fetcher / Source /

            • google-api-objectivec-client / Source / **


            • 将GTM_USE_SESSION_FETCHER = 1添加到预处理器宏。

            • 将文件google-api-objectivec-client / Source / OAuth2 / Touch / GTMOAuth2ViewTouch.xib添加到项目的支持文件组中。将以下文件添加到QuickstartAp p组:


              • google-api-objectivec-client / Source / Services / Drive / Generated / GTLDrive_Sources.m

              • google-api-objectivec-client / Source / Services / Drive / Generated / GTLDrive.h


              • 如果没有自动创建,新的头文件Bridging-Header.h包含以下内容:


                • #importGTMOAuth2ViewControllerTouch.h

                • #importGTLDrive.h


              • 将Build Settings> Objective-C Bridging Header设置为桥接头的绝对路径。


  • I plan to use Google Drive API in my Swift project. I'm trying to add the Drive SDK via CocoaPods (v0.39.0). Below is my Podfile.

    platform :ios, '8.0'
    use_frameworks!
    
    pod 'Google-API-Client/Drive'
    

    I have the use_frameworks! flag added so that CocoaPods can convert Objective-C pods to Swift frameworks instead of static libraries.

    Pod installation is successful. However when I build the project, I get the following error.

    Duplicate interface definition for class 'GTMHTTPUploadFetcher'

    Deleting DerivedData folder and cleaning the project didn't work.

    I also tried without adding the use_frameworks! and then adding the library via a bridging header way. That works without an issue. The thing is all my other dependencies work with it turned on. And unfortunately CocoaPods doesn't support turning that flag for certain pods only.

    Is there a workaround to resolve this issue?


    As stated in Google's docs, Google engineers supposedly monitor questions tagged with google-drive-sdk so I hope at least they'll see this and fix it soon.

    解决方案

    I ran into this same problem. My solution was to not install the Google API Client for iOS using CocoaPods because I was using Swift-based pods and I, therefore, could not remove use_frameworks! to attempt to get around the duplicate header issue.

    I instead installed the library manually by following the detailed instructions at https://developers.google.com/drive/ios/quickstart?ver=swift for Steps 2, 3, and 4. I followed the instructions but applied them to my existing workspace instead of creating a new workspace.

    It's important to note that I had to adjust the paths in User Header Search Paths to match the locations where I actually copied the source code from Google.

    I'm copying the instructions here for reference.

    Step 2: Download the Google Client Library

    Run the following commands to download the library using git:

    • git clone https://github.com/google/google-api-objectivec-client.git
    • git clone https://github.com/google/gtm-oauth2.git
    • git clone https://github.com/google/gtm-session-fetcher.git
    • git clone https://github.com/stig/json-framework.git -b v2.3
    • cp -R gtm-oauth2/Source google-api-objectivec-client/Source/OAuth2
    • cp -R json-framework/Classes google-api-objectivec-client/Source/JSON

    Step 3: Prepare the workspace

    Open Xcode and create a new workspace named "Quickstart". Using File > Add Files to "Quickstart"..., add the following projects to the workspace from the libraries you cloned in the previous step:

    • google-api-objectivec-client/Source/GTL.xcodeproj
    • gtm-session-fetcher/Source/GTMSessionFetcher.xcodeproj

    Select the "GTMSessionFetcher" project and make the following changes:

    • Add a new target of the type iOS > Framework & Library> Cocoa Touch Static Library and name it "GTMSessionFetcherLib".
    • Add all of the .m files in the project's GTMSessionFetcher group to the target's Build Phases > Compile Sources section.

    Select the "GTL" project's "GTLTouchStaticLib" target and make the following changes:

    • Add the library GTMSessionFetcher/libGTMSessionFetcherLib.a to Build Phases > Link Binary with Libraries.
    • Add the absolute path to gtm-session-fetcher/Source/ to Build Settings > User Header Search Paths.
    • Add the flag GTM_USE_SESSION_FETCHER=1 to Build Settings > Preprocessor Macros.
    • Delete the "GTL" project's "GTLFramework" target.
    • In the Project navigator, delete GTL project's GTL Source > Common > HTTPFetcher group.

    Step 4: Prepare the project

    • Create a new iOS > Application > Single View Application project named "QuickstartApp". Set the Language to Swift , and when saving the project set the Add to and Group fields to "Quickstart".
    • Add the following frameworks and libraries to the project's Build Phases > Link Binary with Libraries section: libGTLTouchStaticLib.a
      • Security.framework
      • SystemConfiguration.framework
    • Change the following Build Settings:
    • Add -ObjC -all_load to Other Linker Flags.
    • Add the absolute path to the following directories to User Header Search Paths:
      • gtm-session-fetcher/Source/
      • google-api-objectivec-client/Source/**
    • Add the flag GTM_USE_SESSION_FETCHER=1 to Preprocessor Macros.
    • Add the file google-api-objectivec-client/Source/OAuth2/Touch/GTMOAuth2ViewTouch.xib to the project's Supporting Files group.
    • Add the following files to the QuickstartApp group:
      • google-api-objectivec-client/Source/Services/Drive/Generated/GTLDrive_Sources.m
      • google-api-objectivec-client/Source/Services/Drive/Generated/GTLDrive.h
    • If not created automatically, create a new header file Bridging-Header.h with the following content:
      • #import "GTMOAuth2ViewControllerTouch.h"
      • #import "GTLDrive.h"
    • Set Build Settings > Objective-C Bridging Header to the absolute path of the bridging header.

    这篇关于类'GTMHTTPUploadFetcher'的重复接口定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆