11

Is there any way to disable crash reporting for Ad-Hoc builds? I only want crash reporting for release builds.

I know I can use following code but it only work debug builds.

#if DEBUG == 0
    [Fabric with:@[CrashlyticsKit]];
#endif

Im using Fabric 1.1.3

Edit: I don't want to disable Fabric at all, I just need automatic configurations for Ad-Hoc and Release builds.

Zee
  • 1,865
  • 21
  • 42
  • Possible duplicate of [How to disable Crashlytics iOS library using a flag?](http://stackoverflow.com/questions/28931322/how-to-disable-crashlytics-ios-library-using-a-flag) – mixel Jan 05 '16 at 16:55
  • No, I needed automatic configurations for Ad-Hoc and Release builds, and @rckoenes solution works in that case. – Zee Jan 07 '16 at 17:01
  • https://stackoverflow.com/a/66972059/2692839 – Umair Ali Apr 06 '21 at 15:52

5 Answers5

7

To disable firebase crashlytics for debug mode in swift:

    #if DEBUG
        Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(false)
    #endif
Umair Ali
  • 758
  • 8
  • 17
5

I think you can try this :

#ifndef DEBUG
 [Fabric with:@[CrashlyticsKit]];
#endif
rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • 3
    In preprocessing syntax, `ifndef DEBUG` and `if DEBUG == 0` are not the same at all, because the second one imply that DEBUG is defined with a 0 value and often in release builds, the DEBUG flaf is just not present – Marc-Alexandre Bérubé Jul 21 '15 at 12:12
5

If you use Swift, this woud work:

#if !DEBUG
    Fabric.with([Crashlytics.self])
#endif
Andrey Gordeev
  • 30,606
  • 13
  • 135
  • 162
4

Development builds are also DEBUG builds, You are probably meaning Ad-Hoc builds. Since the release and Ad-Hoc build use the same configuration you will not be able to tell them apart.

You bets option is to create a new configuration for the AppStore. For this configuration add a Preprocessor Macro, Like FABRIC=1

Then in you build code:

#ifdef FABRIC
    [Fabric with:@[CrashlyticsKit]];
#endif
Max MacLeod
  • 26,115
  • 13
  • 104
  • 132
rckoenes
  • 69,092
  • 8
  • 134
  • 166
2

For Swift, Add this key to plist and set it 'NO'.

firebase_crashlytics_collection_enabled

After this, based on user-defined variable in Build Settings, you can configure this.

#if Development
print("Debug 1")
Fabric.sharedSDK().debug = true
#else
print("Debug 0")
Fabric.with([Crashlytics.self])
#endif
ZeroOne
  • 584
  • 4
  • 17