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).
在我的iOS项目中集成谷歌分析SDK有很多困难。我使用的是XCode 7,目标是iOS 7。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时未找到的h文件。
Update
更新
Using pod 'GoogleAnalytics'
and then #import <Google/Analytics.h>
worked better. However then I get the following error:
使用pod 'GoogleAnalytics',然后使用#import <谷歌 analytics。h> 工作更好。然而,我得到了以下错误:
Use of unresolved identifier 'GGLContext'
when I try setup GA from according to Google documentation:
当我尝试从谷歌文档中设置GA时:
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
2 个解决方案
#1
30
Solved it by going away from Googles own tutorial and not use GGLContext
and importing headers directly.
解决它的方法是离开google自己的教程,而不是直接使用GGLContext和导入header。
My podfile:
我的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
:
还添加到用户头搜索路径:
$(SRCROOT)/Pods/GoogleAnalytics (recursive)
#2
7
#import <GoogleAnalytics/GAI.h>
Instead of:
而不是:
#import <GoogleAnalytics.h>
This what worked for me, XCODE9.0.
这对我有效,XCODE9.0。
#1
30
Solved it by going away from Googles own tutorial and not use GGLContext
and importing headers directly.
解决它的方法是离开google自己的教程,而不是直接使用GGLContext和导入header。
My podfile:
我的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
:
还添加到用户头搜索路径:
$(SRCROOT)/Pods/GoogleAnalytics (recursive)
#2
7
#import <GoogleAnalytics/GAI.h>
Instead of:
而不是:
#import <GoogleAnalytics.h>
This what worked for me, XCODE9.0.
这对我有效,XCODE9.0。