9

Can't seem to enable/disable Crashlytics at runtime by a method call in swift - my app is setup with firebase analytics and Crashlytics for firebase - the following call (per the Google dev website) gives me "Use of unresolved identifier 'Crash'" even when importing crashlytics and firebase

Crash.sharedInstance().crashCollectionEnabled = false
Nostradamus
  • 1,497
  • 3
  • 20
  • 34
  • Are you using Fabric or Crashlytics? Pod / binary? Latest version? – Adis Jun 03 '19 at 07:19
  • Appears as if your Crashlytics is not imported. It could also be an issue of dynamic framework usage as these are not loaded until usage. Usage of a static lib cab be better in such scenarios – Ganesh Somani Jun 03 '19 at 07:34
  • I added Firebase analytics to the project, followed by crashlytics per the firebase instructions on google's website. It's the latest version of Firebase and Crashlytics. What import am I missing? – Nostradamus Jun 03 '19 at 14:05

2 Answers2

8

In new SDK you can do it as per documentation:

By default, Crashlytics automatically collects crash reports for all your app's users. To give users more control over the data they send, you can enable opt-in reporting for your users by disabling automatic collection and initializing Crashlytics only for selected users:

Turn off automatic collection by adding a new key to your Info.plist file:

Key: FirebaseCrashlyticsCollectionEnabled 
Value: false 

Enable collection for select users by calling the Crashlytics data collection override at runtime. The override value persists across launches of your app so Crashlytics can automatically collect reports for future launches of that app instance. To opt out of automatic crash reporting, pass false as the override value.

 Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true)
Michal Šrůtek
  • 1,647
  • 16
  • 17
Irina
  • 177
  • 2
  • 4
0

It seems that the Firebase framework that provided that method has been deprecated.

You should now be using the Crashlytics way: https://firebase.google.com/docs/crashlytics/customize-crash-reports#enable_opt-in_reporting