Adam Zein
Adam Zein

Reputation: 21

Swift Use of Unresolved Identifier 'GMServices'

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  let googleMapsApiKey = "AIzaSyDc7eBtBwvAWucUaJcI6chyc9zNhbLQFao"

  func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {



    GMSservices.provideAPIKey(googleMapsApiKey)
    return true
  }

}

I'm having this reoccurring issue where the GMServices error keeps on appearing, yet I have all the relevant framework etc. Any help will be greatly appreciated!

Upvotes: 2

Views: 3550

Answers (4)

nserekolouis
nserekolouis

Reputation: 31

Add these imports at the top of the file

import GoogleMaps

import GooglePlaces

Upvotes: 0

yoninja
yoninja

Reputation: 1962

This happened to me just recently when I updated my cocoapods. Now I see:

  • Using GoogleMaps (1.10.3)
  • COCOAPODS: 0.39.0

The import in the bridging header, #import <GoogleMaps/GoogleMaps.h> used to work.

Now, to resolve the issue, I had to add import GoogleMaps to the Swift file that has the error.

Upvotes: 1

Atul Kaushik
Atul Kaushik

Reputation: 5201

Add a temporary Objective-C file to your project. You may give it any name you like.

Select Yes to configure an Objective-C bridging header.

Delete the temporary Objective-C file you just created.

In the projectName-Bridging-Header.h file just created, add this line:

'#import < GoogleMaps/GoogleMaps.h >'

Edit the AppDelegate.swift file:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    GMSServices.provideAPIKey("AIza....") //iOS API key

    return true
}

Upvotes: 1

Dharmesh Kheni
Dharmesh Kheni

Reputation: 71854

After you imported Google Maps iOS SDK, you need to have a bridge header defined, then the SDK will be recognized.

To create this bridge header, add an arbitrary Objective-C file(eg: a .m file) to your project. Xcode will prompt to ask you if to configure a bridge header for you.

Click Yes to continue.

A file ending with -Bridging-Header.h will be added to your project.

Simply add #import in the bridge header, and you are good to go!

Also, it's safe to delete that temporary Objective-C file now.

For more Information refer this link : http://dubinski.org/wpis/google-maps-sdk-with-swift-tutorial/

Upvotes: 2

Related Questions