Installed Google Drive API, but have the error “no

2019-05-05 04:48发布

I have done every step that this link has instructed (https://developers.google.com/drive/ios/quickstart?ver=swift). However, I am getting an error for the line that says import GoogleAPIClient. The error states "no such module 'GoogleAPIClient'". I have read other threads that have mentioned Ruby and Cocoa Pods and both are up to date in my project.

I'm looking for any suggestion at this point I'm just baffled.

3条回答
劳资没心,怎么记你
2楼-- · 2019-05-05 05:29

I found out what was wrong. I found this answer: can't find Pods.modulemap - looking in wrong directory

The solution worked for me perfectly. It isn't addressing the same issue but the solution also solves this issue

Basically, do this:

  • Open terminal and type the following commands
  • cd ~/Library/Developer/Xcode/DerivedData
  • rm -rf Build/*
  • rm -rf ModuleCache/*
  • Close the terminal
  • Open Xcode and open the project
  • Product > Clean

Should work now!

查看更多
叛逆
3楼-- · 2019-05-05 05:42

Try the following workarounds:

  • Go into your build settings and define the Framework Search Paths to a folder which contains the frameworks in question. If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT) and set it to recursive.
  • FRAMEWORK_SEARCH_PATHS build setting needs to point to the location of the framework.

Check these related threads:

Close the Xcode.

Go into user(you)/Library/Developer/Xcode/DerivedData and delete the folder contents.

If you have a build of you app in a running simulator you'll need to also delete the build folders.

Reopen the Xcode. Clean & Build.

You need 3 things:

(1) Well formed Podfile

platform :ios, '8.0'

target 'GoogleDrive' do
pod 'Google-API-Client/Drive', '~> 1.0'
end

(2) Expose Google API through the bridging headers

#import "GTMOAuth2ViewControllerTouch.h"
#import "GTLDrive.h"

(3) No reference GTLDrive required in the Swift client class

override func viewDidLoad() {
    super.viewDidLoad()
    // ...

    let service:GTLServiceDrive = GTLServiceDrive()
    service.authorizer = GTMOAuth2ViewControllerTouch.authForGoogleFromKeychainForName("Drive

API", clientID: "YOUR_CLIENT_ID_HERE", clientSecret: "YOUR_CLIENT_SECRET_HERE")

    // ...
}

Hope this helps!

查看更多
唯我独甜
4楼-- · 2019-05-05 05:47

Before importing anything, make sure you build the project after the pod has completed the installation.

Also make sure you're using the .xcworkspace file too and not the stand .xcodeproj

查看更多
登录 后发表回答