无法让GoogleMaps SDK在Xcode Test Target上工作(适用于App Target)

安装程序

我已经使用CocoaPods成功将GoogleMaps SDK集成到我的Swift 2项目中。

我的设置几乎是Ray Wenderlich关于这个主题的教程所build议的。 我可以find的唯一区别是,我必须添加此行到AppDelegate:

import UIKit import GoogleMaps // <- THIS LINE @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { ... 

…为了使用框架的类。 本教程build议导入:

 #import <GoogleMaps/GoogleMaps.h> 

而不是桥头。

该应用程序工作没有问题。


问题:

当我试图运行由Xcode自动生成的testing目标时,我得到错误:

没有这样的模块“GoogleMaps”

指向上面的AppDelegate中的swift import语句。

所以,我决定切换到教程中的方式:我在AppDelegate.swift中注释掉import GoogleMaps的行,并向桥接头添加一个Objective-C样式的导入语句。

但是 ,我不能正确的做到:

  1. 如果我使用: #import <GoogleMaps/GoogleMaps.h>#import "GoogleMaps/GoogleMaps.h" ,它会给我:

    使用未parsing的标识符“GMServices”

    在构build应用程序目标时在AppDelegate.swift。

  2. 如果我使用#import "GoogleMaps.h" ,它会给我:

    'GoogleMaps.h':文件未find

    在桥头。

我已经尝试过这个答案的解决scheme,但结果是(令人费解)相同…?


接下来,我检查了两个目标(应用程序和testing)的Build Settings / Search Paths / Framework Search Paths的值。 应用程序目标有条目:

"${PODS_ROOT}/GoogleMaps/Frameworks"

…testing目标缺乏,所以我添加了它,并恢复到快速样式的导入(唯一一个至less在构build应用程序目标时起作用),但是我仍然得到:

 import GoogleMaps <! No such module 'GoogleMaps' 

我怎样才能运行我的应用程序的testing?

所以,事实certificate,我所要做的就是修复Podfile(并运行pod install ),如本答案所述 。

我的老荚文件:

 source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.1' def import_pods pod 'GoogleMaps' end workspace 'MyWorkspace' xcodeproj 'MyApp/MyApp.xcodeproj' target : MyApp do xcodeproj 'MyApp MyApp.xcodeproj' pod 'GoogleMaps' end 

我目前的pod文件:

 source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.1' def import_pods pod 'GoogleMaps' end workspace 'MyWorkspace' xcodeproj 'MyApp/MyApp.xcodeproj' target 'MyApp', :exclusive => true do xcodeproj 'MyApp/MyApp.xcodeproj' import_pods end target 'MyAppTests', :exclusive => true do xcodeproj 'MyApp/MyApp.xcodeproj' import_pods end