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

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

问题描述

我计划在我的 Swift 项目中使用 Google Drive API.我正在尝试通过 CocoaPods (v0.39.0) 添加 Drive SDK.下面是我的 Podfile.

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'

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

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

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

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

类GTMHTTPUploadFetcher"的重复接口定义

删除 DerivedData 文件夹并清理项目无效.

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

我也试过不添加 use_frameworks! 然后通过桥接头方式添加库.这没有问题.问题是我所有其他依赖项都在它打开的情况下工作.不幸的是 CocoaPods 没有 支持仅针对某些 pod 翻转该标志.

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?

正如 Google 的 docs 中所述,Google 工程师应该监控带有 google-drive-sdk 标记的问题,所以我希望至少他们会看到并尽快修复它.

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.

推荐答案

我也遇到了同样的问题.我的解决方案是不安装使用 CocoaPods 的适用于 iOS 的 Google API 客户端,因为我使用的是基于 Swift 的 pod,因此我无法删除 use_frameworks! 以尝试获取围绕重复标题问题.

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.

我按照 https://上的详细说明手动安装了该库developer.google.com/drive/ios/quickstart?ver=swift 用于第 2、3 和 4 步.我按照说明操作,但将它们应用到我现有的工作区,而不是创建一个新工作区.

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.

请务必注意,我必须调整 User Header Search Paths 中的路径以匹配我实际从 Google 复制源代码的位置.

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.

第 2 步:下载 Google 客户端库

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

Run the following commands to download the library using git:

  • git clone https://github.com/google/google-api-objectivec-client.git
  • git 克隆 https://github.com/google/gtm-oauth2.git
  • git 克隆 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

第 3 步:准备工作区

打开 Xcode 并创建一个名为Quickstart"的新工作区.使用 File > Add Files to "Quickstart"...,从您在上一步克隆的库中将以下项目添加到工作区:

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

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

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

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

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

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

  • 将库 GTMSessionFetcher/libGTMSessionFetcherLib.a 添加到 Build Phases > Link Binary with Libraries.
  • 将 gtm-session-fetcher/Source/的绝对路径添加到 Build Settings > User Header Search Paths.
  • 将标志 GTM_USE_SESSION_FETCHER=1 添加到 Build Settings > Preprocessor Macros.
  • 删除GTL"项目的GTLFramework"目标.
  • 在项目导航器中,删除 GTL 项目的 GTL Source > Common > HTTPFetcher 组.

第 4 步:准备项目

  • 创建一个名为QuickstartApp"的新 iOS > 应用程序 > 单一视图应用程序项目.将 Language 设置为 Swift ,并在保存项目时将 Add to 和 Group 字段设置为Quickstart".
  • 将以下框架和库添加到项目的 Build Phases > Link Binary with Libraries 部分:libGTLTouchStaticLib.a
    • 安全性框架
    • SystemConfiguration.framework
    • gtm-session-fetcher/来源/
    • google-api-objectivec-client/Source/**
    • google-api-objectivec-client/Source/Services/Drive/Generated/GTLDrive_Sources.m
    • google-api-objectivec-client/Source/Services/Drive/Generated/GTLDrive.h
    • #import "GTMOAuth2ViewControllerTouch.h"
    • #import "GTLDrive.h"

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

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