Completely disable Firebase/Analytics to stop console spam on app startup

15,627

Solution 1

To the best of my knowledge, these two lines:

[[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:NO];

placed very early in the app delegate's didFinishLaunchingWithOptions: will completely disable FireBase analytics, including stopping all the console output.

I've also since discovered that the Google/SignIn cocoapod is deprecated - the recommended one to use is GoogleSignIn (ie. no '/'). If you use GoogleSignIn, then this doesn't have a dependency on Firebase Analytics, so the original problem goes away. Now I have Google Drive support in my app and don't have Firebase Analytics!

Solution 2

You can find this buried in the output:

<Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging
 set the following application argument: -FIRAnalyticsDebugEnabled

Disabling is the opposite - set the argument: -noFIRAnalyticsDebugEnabled:

enter image description here

Additionally, you can control the default Firebase logging level with the setLoggerLevel method in FIRConfiguration. For example to disable all Firebase logging:

  [[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
  [FIRApp configure];

or in Swift:

FirebaseConfiguration.shared.setLoggerLevel(FirebaseLoggerLevel.min)
FirebaseApp.configure()

More details in the FIRLogger implementation here

Solution 3

Swift 4.0:

FirebaseConfiguration.shared.setLoggerLevel(.min) FirebaseConfiguration.shared.analyticsConfiguration.setAnalyticsCollectionEnabled(false)

Solution 4

In Xcode 11.x (Swift 5 era):

This one can be a bit hairy, you may have to restart XCode even after applying the proper solution below.

  1. Open Scheme: press COMMAND + SHIFT + < (the comma) to open up the Scheme which will drop down from the top of XCode as another window.
  2. On the left select "Run Debug"
  3. select the "Arguments" tab at the top of the window
  4. enter the code below into the "Arguments Passed On Launch" section by pressing the little "+" button on the lower left.

(copy paste this) -FIRDebugDisabled

This will disable Debug mode for Firebase for both Firestore, Firebase, and Fire Analytics.

If you haven't loaded Fire Analytics, then you can simply enter the following code into your AppDelegate.swift file:

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: You can open up your Google info.plist and write "NO" for enabling Firebase. To get Google's info.plist, just click on info.plist file, then at the top click on info.plist in the Navigation window, and it will open up a selector with Google's info.plist as a selectable item. See Figure 2.

Figure 1: What the drop-down looks like. enter image description here

Figure 2: Google's info.plist enter image description here

Share:
15,627
JosephH
Author by

JosephH

I'm a mobile/embedded Software Engineer, living in Scotland and currently the CTO at emobix. We develop iOS &amp; Android apps for clients from all over the world.

Updated on June 02, 2022

Comments

  • JosephH
    JosephH about 2 years

    I've installed Google/SignIn cocoapod into my application (which I need to support GoogleDrive), but it depends on Google/Core which depends on FirebaseAnalytics. I don't want or need FirebaseAnalytics.

    FirebaseAnalytics spams the developer console with 8 lines of output when our app starts:

    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
    

    (I had to add X to the URLs in the above output to get past stackoverflow's URL shortener blocker.)

    I tried setting FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES in my Info.plist, that removed 2 lines, but added another 2 lines to tell me that Analytics is disabled (FFS!).

    This spammed output makes it difficult for our developers to see any console output that is actually important. How can I disable it?

    (Failing that, a suggestion on how to get it outputting each line only once would be really welcome.)

  • JosephH
    JosephH about 7 years
    Thanks; this really helped point me in the right direction - though [FIRApp configure] always throws an exception for me (about a missing sender id) - it seems it's not necessary though, and I tried several variants of adding` -FIRAnalyticsDebugEnabled` to the arguments list and none of them actually removed all 8 lines.
  • JosephH
    JosephH over 6 years
    @ajeetsharma This question and answer are not about crashes. If you have a crash that's a different issue and you should search for a relevant answer or post a new question.
  • Paul Beusterien
    Paul Beusterien over 6 years
    @ajeetsharma Disabling logging isn't likely to make a difference on a crash
  • chb
    chb over 5 years
    You're sure 'FirebaseConfiguration.shared.setLoggerLevel(.min)' is syntactically correct?
  • drfalcoew
    drfalcoew over 5 years
    Yes, I've tested it.
  • Marek Manduch
    Marek Manduch almost 5 years
    for me worked the argument "-FIRDebugDisabled" from the mentioned source code: github.com/firebase/firebase-ios-sdk/blob/master/Firebase/Co‌​re/…
  • I make my mark
    I make my mark over 4 years
    The link to the FIRLogger implementation doesn't work.
  • Paul Beusterien
    Paul Beusterien over 4 years
  • rgkobashi
    rgkobashi over 4 years
    Sending the argument disables the debug mode, not the logging, right?
  • Paul Beusterien
    Paul Beusterien over 4 years
    The logging is the only difference about the debug mode.
  • Krøllebølle
    Krøllebølle about 4 years
    Note to others who cannot make this work: Use -FIRDebugDisabled as described here: stackoverflow.com/a/57334171/1139324
  • Alessandro Francucci
    Alessandro Francucci almost 4 years
    The second one is no longer supported on swift 5 and the latest Firebase