我使用的是Xcode 7.1,部署目标是iOS 9.1.该应用程序是"AreaCalculator",它是用Swift编写的.我做了以下设置框架并导入地图:
$ sudo gem install cocoapods
在"AreaCalculator"下触摸Podfile
在Podfile中我把:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.1'
pod 'GoogleMaps'
Run Code Online (Sandbox Code Playgroud)$ pod安装
在终端:
[!]无法加载插件的 /Library/Ruby/Gems/2.0.0/gems/cocoapods-try-release-fix-0.1.2
规范更新本地规范存储库分析依赖关系下载依赖关系安装GoogleMaps(1.10.5)生成Pods项目集成客户端项目
[!]请关闭所有当前的Xcode会话,并 AreaCalculator.xcworkspace从现在开始用于此项目.发送统计信息Pod安装完成!Podfile中有1个依赖项,安装了1个pod.
之后,我在Navigator中选择了AreaCalculator文件夹并选择File\New\File ...,然后选择iOS\Source\Objective-C File模板并创建一个Bridging文件:
"AreaCalculator-Bridging-Header.h".
然后我在"Link Binary With Libraries"中添加"GoogleMaps.framework"."GoogleMaps.framwork"和""GoogleMaps.bundle"都位于Pods文件夹中.
完成所有这些后,在AppDelegate.swift中,我把:
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
}
}
Run Code Online (Sandbox Code Playgroud)但是,编译器向我显示错误"使用未解析的标识符'GMSServices'".
我不知道我哪里做错了?有人可以帮忙吗?
谢谢!