找不到“Google/Analytics.h”文件 - XCode 7
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33098228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'Google/Analytics.h' file not found - XCode 7
提问by Sunkas
I am having much trouble integrating Google Analytics SDK into my iOS project. I am using XCode 7 and targeting iOS 7. Using Swift 2.0. However I can get the sample working ok (not converting to Swift 2.0 though).
我在将 Google Analytics SDK 集成到我的 iOS 项目中遇到了很多麻烦。我正在使用 XCode 7 并针对 iOS 7。使用 Swift 2.0。但是,我可以让示例正常工作(尽管不会转换为 Swift 2.0)。
I've tried both install via CocoaPods and by copying the files manually from:
我已经尝试通过 CocoaPods 安装和手动复制文件:
https://developers.google.com/analytics/devguides/collection/ios/v3/sdk-download
https://developers.google.com/analytics/devguides/collection/ios/v3/sdk-download
When installing via CocoaPods I've tried both
通过 CocoaPods 安装时,我都尝试过
pod 'Google/Analytics'
,
,
pod 'GoogleAnalytics'
and
和
pod 'Google/Analytics', '~> 1.0.0'
Either case the XCode build fails with error
无论哪种情况,XCode 构建都失败并出现错误
BridgingHeader.h:2:9: 'Google/Analytics.h' file not found
Failed to import bridging header '/Users/jonas.andersson/Projects/MyAppName/MyAppName/Supporting files/BridgingHeader.h'
This on row:
这行:
#import <Google/Analytics.h>
I've also tried to add
我也尝试添加
$(SRCROOT)/Pods/GoogleAnalytics
and the rest of the suggestions from Google/Analytics.h file not found when adding to AppDelegate
添加到 AppDelegate 时未找到来自Google/Analytics.h 文件的其余建议
Update
更新
Using pod 'GoogleAnalytics'
and then #import <Google/Analytics.h>
worked better. However then I get the following error:
使用pod 'GoogleAnalytics'
然后#import <Google/Analytics.h>
效果更好。但是,我收到以下错误:
Use of unresolved identifier 'GGLContext'
when I try setup GA from according to Google documentation:
当我根据 Google 文档尝试设置 GA 时:
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
回答by Sunkas
Solved it by going away from Googles own tutorial and not use GGLContext
and importing headers directly.
通过离开 Google 自己的教程而不是GGLContext
直接使用和导入标头来解决它。
My podfile:
我的播客文件:
platform :ios, '7.0'
use_frameworks!
pod 'GoogleAnalytics'
And BridgingHeader.h
:
并且BridgingHeader.h
:
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIFields.h"
And setup:
并设置:
let gai = GAI.sharedInstance()
let id = "my-GA-id"
gai.trackerWithTrackingId(id)
gai.trackUncaughtExceptions = true
gai.logger.logLevel = GAILogLevel.Verbose
Also added to User Header Search Paths
:
还添加到User Header Search Paths
:
$(SRCROOT)/Pods/GoogleAnalytics (recursive)
回答by Yizhar
#import <GoogleAnalytics/GAI.h>
Instead of:
代替:
#import <GoogleAnalytics.h>
This what worked for me, XCODE9.0.
这对我有用,XCODE9.0。