使用未解析的标识符"GMSServices" [英] Use of Unresolved Identifier 'GMSServices'
问题描述
我正在使用Xcode 7.1,部署目标是iOS 9.1.该应用程序是"AreaCalculator",它是用Swift编写的.我做了以下步骤来设置框架并导入地图:
I am using Xcode 7.1 and the deployment target is iOS 9.1. The app is "AreaCalculator" and it was written in Swift. I did following to set up the framework and import the map:
-
$ sudo gem install cocoapods
$ sudo gem install cocoapods
"AreaCalculator"下的$ touch Podfile
under "AreaCalculator" $ touch Podfile
在我放入的Podfile中:
in Podfile I put:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.1'
pod 'GoogleMaps'
$ pod安装
$ pod install
在终端机中:
[!]无法加载插件/Library/Ruby/Gems/2.0.0/gems/cocoapods-try-release-fix-0.1.2
的规范
更新本地规格存储库
分析依赖关系
下载依赖项
安装GoogleMaps(1.10.5)
生成豆荚项目
整合客户项目
[!] Unable to load a specification for the plugin /Library/Ruby/Gems/2.0.0/gems/cocoapods-try-release-fix-0.1.2
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing GoogleMaps (1.10.5)
Generating Pods project
Integrating client project
[!]从现在开始,请关闭任何当前的Xcode会话并对该项目使用AreaCalculator.xcworkspace
.
发送统计信息
吊舱安装完成! Podfile有1个依赖项,总共1个依赖项
吊舱已安装.
[!] Please close any current Xcode sessions and use AreaCalculator.xcworkspace
for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.
此后,我在导航器中选择了AreaCalculator文件夹.
并选择File \ New \ File…,然后选择iOS \ Source \ Objective-C
文件模板并创建了一个桥接文件:
"AreaCalculator-Bridging-Header.h".
After that, I selected the AreaCalculator folder in the Navigator
and select File\New\File…, then choose the iOS\Source\Objective-C
File template and created a Bridging file:
"AreaCalculator-Bridging-Header.h".
- #import GoogleMaps/GoogleMaps.h
然后在链接二进制文件与库"中添加"GoogleMaps.framework". 并且"GoogleMaps.framwork"和"GoogleMaps.bundle"都位于 Pods文件夹.
Then I add "GoogleMaps.framework" in "Link Binary With Libraries". And both "GoogleMaps.framwork" and ""GoogleMaps.bundle" are in the Pods folder.
完成所有这些操作后,在AppDelegate.swift中,我输入:
After all those done, in the AppDelegate.swift, I put:
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'".
However, the compiler showed me an error "Use of Unresolved Identifier 'GMSServices' ".
我不知道我在哪里做错了?有人可以帮忙吗?
I have no idea where I did wrong? Anyone can help?
谢谢!
推荐答案
我已经通过在AppDelegate.swift中导入GoogleMaps"解决了该问题.
I have solved the problem by "import GoogleMaps" in the AppDelegate.swift.
这篇关于使用未解析的标识符"GMSServices"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!