Use of Unresolved Identifier 'GMSServices'

对着背影说爱祢 提交于 2020-01-13 07:44:06

问题


I am using Xcode 7.1 and the deployment target is iOS 9.1. The app is "AreaCalculator" and it was written in Swift. I did following to set up the framework and import the map:

  1. $ sudo gem install cocoapods

  2. under "AreaCalculator" $ touch Podfile

  3. in Podfile I put:

    source 'https://github.com/CocoaPods/Specs.git'
    platform :ios, '9.1'
    pod 'GoogleMaps'
    
  4. $ pod install

    in the terminal:

    [!] Unable to load a specification for the plugin /Library/Ruby/Gems/2.0.0/gems/cocoapods-try-release-fix-0.1.2 Updating local specs repositories Analyzing dependencies Downloading dependencies Installing GoogleMaps (1.10.5) Generating Pods project Integrating client project

    [!] Please close any current Xcode sessions and use AreaCalculator.xcworkspace for this project from now on. Sending stats Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

  5. After that, I selected the AreaCalculator folder in the Navigator and select File\New\File…, then choose the iOS\Source\Objective-C File template and created a Bridging file:
    "AreaCalculator-Bridging-Header.h".

    • "#import GoogleMaps/GoogleMaps.h
  6. Then I add "GoogleMaps.framework" in "Link Binary With Libraries". And both "GoogleMaps.framwork" and ""GoogleMaps.bundle" are in the Pods folder.

  7. After all those done, in the AppDelegate.swift, I put:

    import UIKit
    
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    
        var window: UIWindow?
        let googleMapsApiKey = "MY_GOOGLE_IOS_API_KEY"
    
        func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
            // Override point for customization after application launch.
            GMSServices.provideAPIKey(googleMapsApiKey)
            return true
        }
    }
    

However, the compiler showed me an error "Use of Unresolved Identifier 'GMSServices' ".

I have no idea where I did wrong? Anyone can help?

Thanks!


回答1:


I have solved the problem by "import GoogleMaps" in the AppDelegate.swift.




回答2:


Add this line in AppDelegate.m

#import "GoogleMaps/GoogleMaps.h"


来源:https://stackoverflow.com/questions/33862893/use-of-unresolved-identifier-gmsservices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!