I have been working with google analytics
fine for the past year and now I am switching to swift
. I have a problem importing it using the pods
[ I have done an extensive search and it seems a problem with [use_frameworks!] that is required by Alamofire
.
在过去的一年里,我一直在使用google analytics,现在我正在转向swift。我在使用pod进行导入时遇到问题[我已经进行了大量搜索,而且似乎Alamofire需要[use_frameworks!]的问题。
I have added the SDK manually, that is libGoogleAnalyticsServices.a
and imported some other files in a bridging file called header-Bridging-Header.h
:
我手动添加了SDK,即libGoogleAnalyticsServices.a,并在名为header-Bridging-Header.h的桥接文件中导入了一些其他文件:
#import <Google/Analytics.h>
#import <libGoogleAnalyticsServices.a>
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"
now in AppDelegate.swift
I am trying to configure tracker from GoogleService-Info.plist.
现在在AppDelegate.swift我试图从GoogleService-Info.plist配置跟踪器。
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
if configureError != nil {
println("Error configuring the Google context: \(configureError)")
}
but it shows an error used of unresolved identifier GGLContext
但它显示了未解析的标识符GGLContext使用的错误
2 个解决方案
#1
5
Google was a bit slow to properly support Cocopods but this has been resolved, now. The tricky bit now is to know which version of Google Analytics pod to use as there are at least three different ones, two of which are authored by Google themselves. For using GA using CocoaPods most likely you should be using the one they officially recommend using, which is listed here: https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift
谷歌适当支持Cocopods有点慢,但现在已经解决了。现在最棘手的一点就是要知道要使用哪个版本的Google Analytics pod,因为至少有三个不同的版本,其中两个由Google自己编写。对于使用CocoaPods使用GA,您最有可能使用他们正式推荐使用的那个,如下所示:https://developers.google.com/analytics/devguides/collection/ios/v3/?ver = swift
as of this writing the pod is pod 'Google/Analytics' - using this GA should work without additional effort and without directly embedding any libraries into your code. Additionally the only thing you need in you bridging header is this:
在撰写本文时,pod是pod'Google / Analytics' - 使用此GA可以在不需要额外工作的情况下工作,也无需在代码中直接嵌入任何库。此外,您在桥接标题中唯一需要的是:
#import <Google/Analytics.h>
For a detailed explanation of why there are so may different pods and which one to use, see this video: https://www.youtube.com/watch?v=JQJd7qyWh5k
有关为何可能使用不同的播放器和使用哪种播放器的详细说明,请参阅此视频:https://www.youtube.com/watch?v = JQJd7qyWh5k
#2
1
into your cocoapods you need to set:
进入你的cocoapods你需要设置:
pod 'Google/Analytics'
If you want to use:
如果你想使用:
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
if configureError != nil {
println("Error configuring the Google context: \(configureError)")
}
If you use:
如果您使用:
pod 'GoogleAnalytics' #(without '/')
GGLContext will not be available :)..
GGLContext将无法使用:) ..
#1
5
Google was a bit slow to properly support Cocopods but this has been resolved, now. The tricky bit now is to know which version of Google Analytics pod to use as there are at least three different ones, two of which are authored by Google themselves. For using GA using CocoaPods most likely you should be using the one they officially recommend using, which is listed here: https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift
谷歌适当支持Cocopods有点慢,但现在已经解决了。现在最棘手的一点就是要知道要使用哪个版本的Google Analytics pod,因为至少有三个不同的版本,其中两个由Google自己编写。对于使用CocoaPods使用GA,您最有可能使用他们正式推荐使用的那个,如下所示:https://developers.google.com/analytics/devguides/collection/ios/v3/?ver = swift
as of this writing the pod is pod 'Google/Analytics' - using this GA should work without additional effort and without directly embedding any libraries into your code. Additionally the only thing you need in you bridging header is this:
在撰写本文时,pod是pod'Google / Analytics' - 使用此GA可以在不需要额外工作的情况下工作,也无需在代码中直接嵌入任何库。此外,您在桥接标题中唯一需要的是:
#import <Google/Analytics.h>
For a detailed explanation of why there are so may different pods and which one to use, see this video: https://www.youtube.com/watch?v=JQJd7qyWh5k
有关为何可能使用不同的播放器和使用哪种播放器的详细说明,请参阅此视频:https://www.youtube.com/watch?v = JQJd7qyWh5k
#2
1
into your cocoapods you need to set:
进入你的cocoapods你需要设置:
pod 'Google/Analytics'
If you want to use:
如果你想使用:
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
if configureError != nil {
println("Error configuring the Google context: \(configureError)")
}
If you use:
如果您使用:
pod 'GoogleAnalytics' #(without '/')
GGLContext will not be available :)..
GGLContext将无法使用:) ..