在 Xcode 上启用 Firebase Analytics

Turning Firebase Analytics on on Xcode

我正在尝试测试我的 Firebase Analytics 的实施。他们在 documentation 中声明:

Enable debug mode by passing the -FIRDebugEnabled argument to the application. You can add this argument in the application’s Xcode scheme. When debug mode is enabled via -FIRDebugEnabled, further executions of the application will also be in debug mode. In order to return to default mode, you must explicitly disable the debug mode with the application argument -FIRDebugDisabled.

不幸的是,我不明白我在哪里设置了这个方案。在 Android 这很容易。帮助将不胜感激。

我在 Google 的替代页面上找到了答案:

https://firebase.google.com/docs/analytics/ios/start

  1. In Xcode, select Product > Scheme > Edit scheme...
  2. Select Run from the left menu.
  3. Select the Arguments tab.
  4. In the Arguments Passed On Launch section, add -FIRAnalyticsDebugEnabled.

我希望 Google 停止发布半生不熟的产品和文档。可以在全球范围内节省数十万小时

我试过编辑方案并添加参数,https://firebase.google.com/docs/analytics/ios/start但它对我不起作用。此外,我在配置 FirebaseApp 后添加了以下代码,在 AppDelegate,didFinishLaunchingWithOptions

    FirebaseApp.configure()
    Analytics.setAnalyticsCollectionEnabled(true)

它对我有用。希望对你也有帮助。

我认为您应该检查 XCode 上的控制台日志。因为我会显示log

To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see https://help.apple.com/xcode/mac/8.0/#/dev3ec8a1cb4)

再检查一遍,如果没有:

  • 添加密钥 FirebaseCrashlyticsCollectionEnabled 在 Info.plist
  • 中的值为 true
  • 在 GoogleService 中设置键 IS_ANALYTICS_ENABLED 为真-Info.plist
  • 确保文件 GoogleService-Info.plist 添加所有目标并保存在根项目中