【发布时间】:2017-06-06 12:15:53
【问题描述】:
我试图找到有关如何在 Swift 3 中使用 Google Analytics 的信息,即使看起来有些人成功了,我自己也无法使其工作。
Google Analytics 文档没有帮助,它仅适用于 Swift 2。
我在 3.17.0 版本中使用了 pod“Google/Analytics”,并尝试将这一行添加到桥接头文件中,正如一些人提到的:
#import <Google/Analytics.h>
但是我收到一个错误,关于 Xcode 抱怨桥接头不适用于 Swift 3。
然后我尝试按照另一篇文章的建议在 .h 中添加相同的行,但也不起作用,Xcode 抱怨“在框架模块 XXX 中包含非模块化标头”。
我尝试将“允许框架模块中的非模块化包含”设置为“是”,但它没有改变任何东西,仍然出现同样的错误。
我尝试的最后一件事是添加:
import Google
在我使用 Google Analytics 的文件中,但现在 GAI 无法识别。
// Configure tracker from GoogleService-Info.plist.
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
// Optional: configure GAI options.
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not configured correctly")
}
gai.trackUncaughtExceptions = true // report uncaught exceptions
gai.logger.logLevel = GAILogLevel.verbose // remove before app release
有什么建议吗?
【问题讨论】:
-
imo,您已经完成了尽职调查,框架有些问题。考虑向谷歌提交错误?
标签: ios xcode google-analytics swift3 ios9