找不到"Google/Analytics.h"文件-XCode 7 [英] 'Google/Analytics.h' file not found - XCode 7

查看:135
本文介绍了找不到"Google/Analytics.h"文件-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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆