1.Return to Xcode and drag the GoogleMaps.framework file you downloaded into the Frameworks folder. When prompted, check Copy items if needed, make sure the Feed Me target is checked and click Finish:
一開始請建立一個Swift專案
把GoogleMapSDK下載的GoogleMap.framework檔案拖到Xcode開啟的專案中
彈跳視窗出來時選擇target , 並且勾選Copy items if needed
2.Right-click on GoogleMaps.framework in the Project Navigator and select Show In Finder. Expand the framework and go into the Resources folder. Drag the GoogleMaps.bundle from the Resources folder to your Frameworks folder in Xcode. This time, make sure Copy items if needed isn’t checked, then click Finish.
- AVFoundation.framework
- CoreData.framework
- CoreLocation.framework
- CoreText.framework
- GLKit.framework
- ImageIO.framework
- libc++.dylib
- libicucore.dylib
- libz.dylib
- OpenGLES.framework
- QuartzCore.framework
- SystemConfiguration.framework
4.Once again, select the Feed Me project at the top of the Project Navigator, only this time, choose the Feed Me Project rather than the target. Select the Build Settings tab, and in Other Linker Flags add -ObjC
5.Go to File \ New \ File… and select the iOS \ Source \ Objective-C file template. Name the file whatever you like — you’ll delete this file in a moment — then save it. When save the file, Xcode offers to create an Objective-C bridging header file for you like so:
lick Yes and Xcode will create the bridging header file and add it to your project. Delete the original Objective-C file as you no longer need it.
Open the newly created Feed Me-Bridging-Header.h and add the following line of code to the bottom of the file:
#import <GoogleMaps/GoogleMaps.h>
|
The Google Maps SDK is now available in your Swift app — it’s finally time to write some code!
6.AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
//1
let googleMapsApiKey = "YOUR_GOOGLE_IOS_API_KEY"
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//2
GMSServices.provideAPIKey(googleMapsApiKey)
return true
}
沒有留言:
張貼留言