找不到"Google/Analytics.h"文件-XCode 7 [英] 'Google/Analytics.h' file not found - XCode 7
问题描述
将Google Analytics(分析)SDK集成到我的iOS项目时遇到了很多麻烦.我正在使用XCode 7,并定位到iOS7.使用Swift 2.0.但是,我可以使示例正常运行(尽管不会转换为Swift 2.0).
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).
我尝试通过CocoaPods进行安装,也尝试通过以下方式手动复制文件:
I've tried both install via CocoaPods and by copying the files manually from:
https://developers.google.com/analytics/devguides/collection/ios/v3/sdk-download
通过CocoaPods安装时,我都尝试过
When installing via CocoaPods I've tried both
pod 'Google/Analytics'
,
pod 'GoogleAnalytics'
和
pod 'Google/Analytics', '~> 1.0.0'
无论哪种情况,XCode构建都会因错误而失败
Either case the XCode build fails with error
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'
此行:
#import <Google/Analytics.h>
我也尝试添加
$(SRCROOT)/Pods/GoogleAnalytics
和 Google/添加到AppDelegate时找不到Analytics.h文件
更新
使用pod 'GoogleAnalytics'
,然后使用#import <Google/Analytics.h>
效果更好.但是然后我得到以下错误:
Using pod 'GoogleAnalytics'
and then #import <Google/Analytics.h>
worked better. However then I get the following error:
Use of unresolved identifier 'GGLContext'
当我尝试根据Google文档设置GA时:
when I try setup GA from according to Google documentation:
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
推荐答案
通过脱离Google自己的教程而不使用GGLContext
并直接导入标头来解决了该问题.
Solved it by going away from Googles own tutorial and not use GGLContext
and importing headers directly.
我的Podfile:
platform :ios, ’7.0’
use_frameworks!
pod 'GoogleAnalytics'
和BridgingHeader.h
:
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIFields.h"
设置:
let gai = GAI.sharedInstance()
let id = "my-GA-id"
gai.trackerWithTrackingId(id)
gai.trackUncaughtExceptions = true
gai.logger.logLevel = GAILogLevel.Verbose
也已添加到User Header Search Paths
:
$(SRCROOT)/Pods/GoogleAnalytics (recursive)
这篇关于找不到"Google/Analytics.h"文件-XCode 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!