122

I am trying to test the implementation of my Firebase Analytics. In their documentation they state that:

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.

Unfortunately I do not understand where it is that I set this scheme. In Android this was easy. Help would be appreciated.

checklist
  • 12,340
  • 15
  • 58
  • 102

3 Answers3

356

I have found the answer on this alternative page of 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.

I wish Google would stop releasing half baked products and documentation. Could save hundreds of thousands of hours worldwide

checklist
  • 12,340
  • 15
  • 58
  • 102
  • 3
    I don't think this is half backed products or documentation as you commented. The log cannot be too long and it does state to pass into the application. The official documentation you gave also states how to turn it on so I don't get what that opinion is about "half baked". If you can provide help, that is really helpful but please don't give false impression. – adbitx Apr 03 '17 at 17:14
  • 45
    I agree with the sentiment that the offical docs could be better – user230910 Oct 10 '17 at 12:10
  • how to do the same thing for build? – Vyachaslav Gerchicov Oct 18 '17 at 14:49
  • 7
    Which is the correct argument -FIRAnalyticsDebugEnabled or -FIRDebugEnabled ?? – Carlos Apr 10 '18 at 17:30
  • 17
    -FIRAnalyticsDebugEnabled or -FIRDebugEnabled are correct. But if you want to stop it, you need to use -FIRDebugDisabled. – Sean Apr 11 '18 at 07:40
  • 1
    The docs say, that this setting will be persisted. For how long? Where? In the App? On my Mac? Do I need to disable it explicitly before doing a release build? – heyfrank May 21 '19 at 11:26
  • 23
    "Specify the following command line argument in Xcode" is definitely document with very, very low quality. And using scheme setting itself is poor design, everyone would understand "Firebase.setDebug(true)", but at least people visit this page are having problem. – superarts.org Jul 09 '19 at 20:22
  • 2
    -FIRDebugEnabled translates into UserDefaults key kFIRPersistedDebugModeKey = "/google/firebase/debug_mode". It's done in FIRLogger.FIRLoggerInitializeASL method. Once you run your app with -FIRDebugEnabled, mentioned key is set with "true" value in user defaults. Running your app with -FIRDebugDisabled will remove kFIRPersistedDebugModeKey from UserDefaults. As well as removing app from device. So @fl034, you don't have to disable it explicitly for release build. (BTW, AFAIK, launch arguments are applied only when you run your app from Xcode; release build will not process them) – tahavath Dec 01 '20 at 10:05
  • 1
    @tahavath Thank you so much for this: "BTW, AFAIK, launch arguments are applied only when you run your app from Xcode; release build will not process them" That is the one missing part (in addition to accepted answer's instructions) that eventually made it work for the iOS debug event streaming. – Ugo Nov 10 '22 at 13:47
11

I tried editing scheme and adding parameters, https://firebase.google.com/docs/analytics/ios/start but it did not work for me. In addition, I added following code after configuring FirebaseApp, at AppDelegate, didFinishLaunchingWithOptions

    FirebaseApp.configure()
    Analytics.setAnalyticsCollectionEnabled(true)

and it worked for me. I hope it helps you too.

Burcu Kutluay
  • 472
  • 6
  • 14
  • 2
    Analytics collection is enabled by default, so that line is not necessary. Per documentation: `Sets whether analytics collection is enabled for this app on this device. This setting is persisted across app sessions. By default it is enabled.` – Politta Jan 07 '20 at 20:19
  • 6
    For some reason the analytics flag was set to `false` in Google plist generated by Firebase Console. Enabling manually in code by `Analytics.setAnalyticsCollectionEnabled(true)` works nice. – smartwolf Jun 07 '21 at 11:33
  • tried everything (info.plist etc.) this is the only way to have it working as expected! – Marino Di Clemente Oct 18 '21 at 17:03
  • Same issue as @smartwolf, plist generated had a `0` for Analytics collection. Changing to `1` seems to fix the issue. This does not seem to be mentioned in the documentation : https://firebase.google.com/docs/analytics/debugview – TimD Dec 18 '21 at 02:38
3

I think you should check console log on XCode. Because I will show log

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

Check again, if you don't:

  • Add key FirebaseCrashlyticsCollectionEnabled has value true in Info.plist
  • set key IS_ANALYTICS_ENABLED is true in GoogleService-Info.plist
  • Make sure file GoogleService-Info.plist add will all targets and save in root project
  • 7
    IS_ANALYTICS_ENABLED is not about Firebase it's about Google analytics. https://stackoverflow.com/questions/38549074/firebase-for-ios-googleservice-info-plist-property-is-analytics-enabled-set-t – えるまる Feb 09 '21 at 13:02