Google/Analytics.h 测试时未找到文件

Google/Analytics.h file not found when Testing

我包含了 BridgingHeader.h 但是在导入 Google/Analytics.h 时找不到该文件。

这在应用程序中工作正常,它只会在测试时抛出错误。

不确定问题出在哪里,如有任何见解,我们将不胜感激。

我有一个类似的问题,并通过打开你的 podfile 并如下所示修改它,将 Google Analytics pod 添加到测试和 uitests 目标来修复它:

target 'MyApp' do
pod 'Google/Analytics'
end

target 'MyAppTests' do
pod 'Google/Analytics'
end

target 'MyAppUITests' do
pod 'Google/Analytics'
end

一旦完成,我必须 运行 pod install 两次然后它起作用了。

花了将近 2 个小时的搜索,终于找到了所有疯狂的正确解决方案!上面接受的解决方案有效,但给出了很多 Class GAIUtil is implemented in both... 警告,这并不完全正确。

解决方案

您需要使用cocoapods 1.0.0.beta6+

您的测试目标应在您的 Podfile 中定义如下:

target 'App' do
    pod 'GoogleAnalytics' , '~> 3.0'
    # your other pods

    target 'AppTests' do
        inherit! :search_paths
        # your other testing pods/frameworks
    end
end

pod update.

在那里找到的所有东西https://github.com/CocoaPods/CocoaPods/issues/4626#issuecomment-210402349