Duplicate interface definition for class 'GTMHTTPUploadFetcher'

I plan to use the Google Drive APIs in my Swift project. I am trying to add a drive SDK through CocoaPods (v0.39.0). Below is my subfile.

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

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

Installation substitution completed successfully. However, when I create a project, I get the following error.

Duplicate interface definition for class 'GTMHTTPUploadFetcher'

Deleting the DerivedData folder and cleaning up the project did not help.

I also tried without adding use_frameworks! and then adding the library through the header header. It works without a problem. The fact is that all my other addictions work with him. And, unfortunately, CocoaPods does not support that this flag is displayed only for certain containers.

Is there any workaround?


As stated in the Google docs , Google engineers presumably control issues tagged with google-drive-sdk, so I hope that at least they will see this and fix it soon.

+7
ios swift cocoapods google-drive-sdk
source share
4 answers

I ran into this problem. My solution was to not install the Google API client for iOS using CocoaPods because I used Swift subsystems and therefore I could not remove use_frameworks! to try to work around the duplicate header problem.

Instead, I installed the library manually by following the detailed instructions 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, and not to create a new workspace.

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

I copy 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 called Quick Start. Using File> Add Files To Quick Start ..., add the following projects to the workspace from the libraries that you cloned in the previous step:

  • Google-api-ObjectiveC-client / Source / GTL.xcodeproj
  • GTM session-collector / Source / GTMSessionFetcher.xcodeproj

Select the GTMSessionFetcher project and make the following changes:

  • Add a new target such as iOS> Framework and Library> Cocoa. Click Static Library and name it "GTMSessionFetcherLib".
  • Add all .m files to the GTMSessionFetcher group of the project in the target phase assembly> Compile Sources.

Select the goal of the GTLTouchStaticLib "GTL" project and make the following changes:

  • Add library GTMSessionFetcher / libGTMSessionFetcherLib.a to create phases> Link to binary files with libraries.
  • Add the absolute path to gtm-session-fetcher / Source / to create the settings> User Header Search Paths.
  • Add the flag GTM_USE_SESSION_FETCHER = 1 to configure parameters> Preprocessor macros.
  • Delete the GTLFramework "GTL" project goal.
  • In the project navigator, delete the GTL project GTL Source> Common> HTTPFetcher group.

Step 4: Prepare the project

  • Create an iOS app> Application> Single View Application named "QuickstartApp". Set the Language to Swift, and when saving the project, set the "Add" and "Group" fields to "Quick Start".
  • Add the following structures and libraries to Create Phases> Linking Binary Files to Libraries: libGTLTouchStaticLib.a
    • Security.framework
    • SystemConfiguration.framework
  • Change the following build settings:
  • Add -ObjC -all_load to other linker flags.
  • Add an absolute path to the following directories in the user header search path:
    • GTM-session-collector / Source /
    • Google-api-ObjectiveC-client / Source / **
  • Add the GTM_USE_SESSION_FETCHER = 1 flag to the preprocessor macros.
  • Add the google-api-objectivec-client / Source / OAuth2 / Touch / GTMOAuth2ViewTouch.xib file to the support file support group.
  • Add the following files to the QuickstartApp group:
    • Google-api-ObjectiveC-client / Source / Services / Drive / Formed / GTL; DRive_Sources.m
    • Google-api-ObjectiveC-client / Source / Services / Drive / Formed / GTL; DRive.h
  • If it is not automatically created, create a new Bridging-Header.h header file with the following contents:
    • #import "GTMOAuth2ViewControllerTouch.h"
    • #import "GTLDrive.h"
  • Set assembly options> Objective-C Crossing Bridge to the absolute bridge header path.
+3
source

According to Google, this error is caused by the use of cocoapod by a third party, but now they have an official package in the project ( https://github.com/google/google-api-objectivec-client/blob/master/GoogleAPIClient.podspec ), and the problem needs to be fixed.

See: https://github.com/google/google-api-objectivec-client/issues/103

Using:

pod 'GoogleAPIClient/Drive', '~> 1.0'

and possibly also:

pod 'GTMOAuth2' or pod 'Google/SignIn'

+4
source

The only workaround I found was that you need to go to the three projects that Google Drive imported and check how the import works. Now its importing headers, not frameworks (three structures depend on each other). You just have to do it manually and it will work.

I don't have code samples to show you, but I know that I got it to work for the last time this way.

0
source

A simple solution here:

Go to the editing scheme β†’ Choose Create β†’ Create to disable Parallelize Build

Now run the application

0
source

All Articles