如何禁用/删除FirebaseAnalytics

我从CocoaPod更新“Google / Analytics”并获取FirebaseAnalytics。

之后,每次运行项目时,FirebaseAnalytics都会显示很多错误日志。

目前我不使用这个库,并想删除它。 不幸的是,我找不到任何方法来禁用/删除Pod。

这是Podfileconfiguration

target 'myApp' do inhibit_all_warnings! use_frameworks! pod 'Google/Analytics' end 

控制台日志:

 <FIRAnalytics/DEBUG> Debug mode is on <FIRAnalytics/INFO> Firebase Analytics v.3200000 started <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see 'https://developer.apple.com/library/ios/recipes/xcode_help-scheme_editor/Articles/SchemeRun.html') <FIRAnalytics/DEBUG> Debug logging enabled <FIRAnalytics/DEBUG> Firebase Analytics is monitoring the network status <FIRAnalytics/DEBUG> Uploading data. Host: https://play.googleapis.com/log <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist <FIRAnalytics/INFO> Firebase Analytics disabled ... <FIRAnalytics/DEBUG> Network status has changed. code, status: 2, Connected <FIRAnalytics/DEBUG> Network status has changed. code, status: 2, Connected <FIRAnalytics/DEBUG> Received SSL challenge for host. Host: https://play.googleapis.com/log <FIRAnalytics/DEBUG> Cancelling authentication challenge for host. Host: https://play.googleapis.com/log <FIRAnalytics/ERROR> Encounter network error. Error: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://play.googleapis.com/log, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=https://play.googleapis.com/log} ... 

更新:我也尝试在Info.plist中添加FirebaseAppDelegateProxyEnabled = false,但它也不起作用。

在这里输入图像说明

要在您的应用中停用Firebase Analytics收集数据,请参阅此处的说明。

总之,要临时禁用,请在GoogleServices-Info.plist文件中将FIREBASE_ANALYTICS_COLLECTION_ENABLED设置为NO 。 要永久禁用,请在相同的plist文件中将FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED设置为YES

我最近碰到类似的问题。 我使用的是Google Analytics(分析),但不想或不需要Firebase分析,如果您按照文档进行操作 ,则默认安装该分析。 通过podspecssearch之后。 我发现Google/Analytics类别对Google/Core有依赖性。 core subspec依次取决于FirebaseAnalytics ,这就是为什么它正在安装。

但是,我注意到Analytics类别也依赖于GoogleAnalytics cocoapods。

所以我改变了我的Podfile:

 target 'myApp' do inhibit_all_warnings! use_frameworks! pod 'Google/Analytics' end 

对此:

 target 'myApp' do inhibit_all_warnings! use_frameworks! pod 'GoogleAnalytics' end 

因此, Google/Analytics.h伞形标题不再可用,您需要手动添加正确的标题或创build自己的伞形标题,其中包括:

 #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" 

如果你在Swift项目中这样做,则需要将这些文件添加到桥头 ,而不是伞头。

在我看来,这是一个很小的代价,不要被迫安装FirebaseAnalytics的cocoapod。

更新

尽pipeGoogle的文档尚未更新,但是他们的podspec现在会告诉您直接使用GoogleAnalytics Pod

这些日志实际上不是来自Firebase Analytics,而是Firebase Core SDK(基于它发送到的URL)。 因此,停用Firebase Analytics不会消除这些日志。 我猜设备networking出现问题,Firebase SDK的请求被取消了。