使用未解析的标识符'GMSServices'

问题描述 投票:8回答:2

我使用的是Xcode 7.1,部署目标是iOS 9.1。该应用程序是“AreaCalculator”,它是用Swift编写的。我做了以下设置框架并导入地图:

  1. $ sudo gem install cocoapods
  2. 在“AreaCalculator”下触摸Podfile
  3. 在Podfile中我把: source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.1' pod 'GoogleMaps'
  4. $ 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。
  5. 之后,我在Navigator中选择了AreaCalculator文件夹并选择File \ New \ File ...,然后选择iOS \ Source \ Objective-C File模板并创建一个Bridging文件: “AreaCalculator桥接-Header.h”。 “#import GoogleMaps / GoogleMaps.h
  6. 然后我在“Link Binary With Libraries”中添加“GoogleMaps.framework”。 “GoogleMaps.framework”和“”GoogleMaps.bundle“都位于Pods文件夹中。
  7. 完成所有这些后,在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 } }

但是,编译器向我显示错误“使用未解析的标识符'GMSServices'”。

我不知道我哪里做错了?有人可以帮忙吗?

谢谢!

ios google-maps-sdk-ios
2个回答
43
投票

我通过AppDelegate.swift中的“import GoogleMaps”解决了这个问题。


1
投票

在AppDelegate.m中添加此行

#import "GoogleMaps/GoogleMaps.h"
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.