完全禁用 Firebase/Analytics 以在应用程序启动时停止控制台垃圾邮件
Completely disable Firebase/Analytics to stop console spam on app startup
我已经在我的应用程序中安装了 Google/SignIn cocoapod(我需要它支持 GoogleDrive),但它依赖于 Google/Core,后者依赖于 FirebaseAnalytics。我不想也不需要 FirebaseAnalytics。
当我们的应用程序启动时,FirebaseAnalytics 向开发者控制台发送 8 行垃圾邮件输出:
2017-06-07 18:07:19.612994+0100 son[2909:877661] [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://gooX.gl/9vSsPb
2017-06-07 18:07:19.613 son[2909] <Warning> [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://gooX.gl/9vSsPb
2017-06-07 18:07:19.613896+0100 son[2909:877661] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3900000 started
2017-06-07 18:07:19.614 son[2909] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3900000 started
2017-06-07 18:07:19.614525+0100 son[2909:877661] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://gooX.gl/RfcP7r)
2017-06-07 18:07:19.614 son[2909] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://gooX.gl/RfcP7r)
2017-06-07 18:07:19.622560+0100 son[2909:877662] [Firebase/Analytics][I-ACS023013] Firebase Analytics disabled
2017-06-07 18:07:19.623 son[2909] <Notice> [Firebase/Analytics][I-ACS023013] Firebase Analytics disabled
(我必须将 X 添加到上面输出中的 URLs 才能通过 Whosebug 的 URL shortener blocker。)
我尝试在 Info.plist 中将 FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED 设置为 YES,删除了 2 行,但添加了另外 2 行告诉我 Analytics 已禁用(FFS!)。
这种垃圾输出让我们的开发人员很难看到任何真正重要的控制台输出。我怎样才能禁用它?
(如果做不到这一点,非常欢迎提出如何让它每行只输出一次的建议。)
你可以在输出中找到这个:
<Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging
set the following application argument: -FIRAnalyticsDebugEnabled
禁用则相反 - 设置参数:-noFIRAnalyticsDebugEnabled:
此外,您可以使用 FIRConfiguration 中的 setLoggerLevel 方法控制默认的 Firebase 日志记录级别。例如禁用所有 Firebase 日志记录:
[[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
[FIRApp configure];
或 Swift:
FirebaseConfiguration.shared.setLoggerLevel(FirebaseLoggerLevel.min)
FirebaseApp.configure()
FIRLogger 实现中的更多详细信息here
据我所知,这两行:
[[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:NO];
放置在应用委托的早期 didFinishLaunchingWithOptions:
将完全禁用 FireBase 分析,包括停止所有控制台输出。
我还发现 Google/SignIn
cocoapod 已被弃用 - 推荐使用的是 GoogleSignIn
(即没有“/”)。如果您使用 GoogleSignIn
,那么它对 Firebase Analytics 没有依赖性,因此原来的问题就消失了。现在我的应用程序中有 Google Drive 支持,但没有 Firebase Analytics!
Swift 4.0:
FirebaseConfiguration.shared.setLoggerLevel(.min)
FirebaseConfiguration.shared.analyticsConfiguration.setAnalyticsCollectionEnabled(false)
在Xcode11.x(Swift5时代):
这个可能有点麻烦,您可能需要重新启动 XCode 即使在应用下面的正确解决方案后也是如此。
- 打开 Scheme:按 COMMAND + SHIFT + <(逗号)打开将从 XCode 顶部下拉的 Scheme 作为另一个 window.
- 左边select》运行调试
- select window
顶部的“参数”选项卡
- 按下左下角的小“+”按钮,将下面的代码输入“启动时传递的参数”部分。
(复制粘贴这个)
-FIRDebugDisabled
这将为 Firestore、Firebase 和 Fire Analytics 禁用 Firebase 的调试模式。
如果您尚未加载 Fire Analytics,则只需将以下代码输入 AppDelegate.swift 文件即可:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
let db = Firestore.firestore()
// This below is the line of code to enter, but it won't stop Firebase Analytics from printing its mess in the consoleLog, but this works if you're not using FireBase Analytics.
FirebaseConfiguration.shared.setLoggerLevel(.min)
return true
}
NOTE/ADDITIONAL:您可以打开您的 Google info.plist 并写上“否”以启用 Firebase。要获取 Google 的 info.plist,只需单击 info.plist 文件,然后在顶部单击导航 window 中的 info.plist,它将打开select或 Google 的 info.plist 作为 select 可用物品。见图 2。
图 1:下拉菜单的外观。
图 2:Google 的 info.plist
我已经在我的应用程序中安装了 Google/SignIn cocoapod(我需要它支持 GoogleDrive),但它依赖于 Google/Core,后者依赖于 FirebaseAnalytics。我不想也不需要 FirebaseAnalytics。
当我们的应用程序启动时,FirebaseAnalytics 向开发者控制台发送 8 行垃圾邮件输出:
2017-06-07 18:07:19.612994+0100 son[2909:877661] [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://gooX.gl/9vSsPb
2017-06-07 18:07:19.613 son[2909] <Warning> [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://gooX.gl/9vSsPb
2017-06-07 18:07:19.613896+0100 son[2909:877661] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3900000 started
2017-06-07 18:07:19.614 son[2909] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3900000 started
2017-06-07 18:07:19.614525+0100 son[2909:877661] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://gooX.gl/RfcP7r)
2017-06-07 18:07:19.614 son[2909] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://gooX.gl/RfcP7r)
2017-06-07 18:07:19.622560+0100 son[2909:877662] [Firebase/Analytics][I-ACS023013] Firebase Analytics disabled
2017-06-07 18:07:19.623 son[2909] <Notice> [Firebase/Analytics][I-ACS023013] Firebase Analytics disabled
(我必须将 X 添加到上面输出中的 URLs 才能通过 Whosebug 的 URL shortener blocker。)
我尝试在 Info.plist 中将 FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED 设置为 YES,删除了 2 行,但添加了另外 2 行告诉我 Analytics 已禁用(FFS!)。
这种垃圾输出让我们的开发人员很难看到任何真正重要的控制台输出。我怎样才能禁用它?
(如果做不到这一点,非常欢迎提出如何让它每行只输出一次的建议。)
你可以在输出中找到这个:
<Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging
set the following application argument: -FIRAnalyticsDebugEnabled
禁用则相反 - 设置参数:-noFIRAnalyticsDebugEnabled:
此外,您可以使用 FIRConfiguration 中的 setLoggerLevel 方法控制默认的 Firebase 日志记录级别。例如禁用所有 Firebase 日志记录:
[[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
[FIRApp configure];
或 Swift:
FirebaseConfiguration.shared.setLoggerLevel(FirebaseLoggerLevel.min)
FirebaseApp.configure()
FIRLogger 实现中的更多详细信息here
据我所知,这两行:
[[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:NO];
放置在应用委托的早期 didFinishLaunchingWithOptions:
将完全禁用 FireBase 分析,包括停止所有控制台输出。
我还发现 Google/SignIn
cocoapod 已被弃用 - 推荐使用的是 GoogleSignIn
(即没有“/”)。如果您使用 GoogleSignIn
,那么它对 Firebase Analytics 没有依赖性,因此原来的问题就消失了。现在我的应用程序中有 Google Drive 支持,但没有 Firebase Analytics!
Swift 4.0:
FirebaseConfiguration.shared.setLoggerLevel(.min)
FirebaseConfiguration.shared.analyticsConfiguration.setAnalyticsCollectionEnabled(false)
在Xcode11.x(Swift5时代):
这个可能有点麻烦,您可能需要重新启动 XCode 即使在应用下面的正确解决方案后也是如此。
- 打开 Scheme:按 COMMAND + SHIFT + <(逗号)打开将从 XCode 顶部下拉的 Scheme 作为另一个 window.
- 左边select》运行调试
- select window 顶部的“参数”选项卡
- 按下左下角的小“+”按钮,将下面的代码输入“启动时传递的参数”部分。
(复制粘贴这个) -FIRDebugDisabled
这将为 Firestore、Firebase 和 Fire Analytics 禁用 Firebase 的调试模式。
如果您尚未加载 Fire Analytics,则只需将以下代码输入 AppDelegate.swift 文件即可:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
let db = Firestore.firestore()
// This below is the line of code to enter, but it won't stop Firebase Analytics from printing its mess in the consoleLog, but this works if you're not using FireBase Analytics.
FirebaseConfiguration.shared.setLoggerLevel(.min)
return true
}
NOTE/ADDITIONAL:您可以打开您的 Google info.plist 并写上“否”以启用 Firebase。要获取 Google 的 info.plist,只需单击 info.plist 文件,然后在顶部单击导航 window 中的 info.plist,它将打开select或 Google 的 info.plist 作为 select 可用物品。见图 2。
图 1:下拉菜单的外观。
图 2:Google 的 info.plist