Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot access Google Map Framework in Swift AppDelegate file

I'm studying Swift and am struggling to figure out how to integrate the Google Map SDK frameworks. I created a new project in Xcode 6, imported the frameworks required as per Google Map SDK instructions for iOS.

However when I import the Google Maps framework using (import )to the AppDelegate.swift file the framework isn't recognised.

Can't find a solution anywhere. Please help.

like image 926
Cathal Avatar asked Jun 23 '14 09:06

Cathal


2 Answers

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 <GoogleMaps/GoogleMaps.h> in the bridge header, and you are good to go!

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

like image 102
Aaron He Avatar answered Nov 05 '22 23:11

Aaron He


You can now install SDK via CocoaPods, and you wont need to add the Bridging Header. View this tutorial(Google Maps iOS SDK Link) and just add the following code to your AppDelegate's didFinichLaunchingWithOptions function.

GMSServices.provideAPIKey("API_KEY")
like image 31
danielsalare Avatar answered Nov 06 '22 00:11

danielsalare