How to disable Crashlytics for iOS during development?
Asked Answered
O

5

12

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.

Omaomaha answered 17/4, 2015 at 7:37 Comment(3)
Possible duplicate of How to disable Crashlytics iOS library using a flag?Baptism
No, I needed automatic configurations for Ad-Hoc and Release builds, and @rckoenes solution works in that case.Omaomaha
https://mcmap.net/q/293566/-new-firebase-crashlytics-disable-in-debug-modeMigraine
H
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
Haply answered 17/4, 2015 at 8:14 Comment(0)
M
9

To disable firebase crashlytics for debug mode in swift:

    #if DEBUG
        Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(false)
    #endif
Migraine answered 6/4, 2021 at 15:50 Comment(1)
Read the documentation for this method just in case, you may want to use info plist instead.Carilla
D
5

I think you can try this :

#ifndef DEBUG
 [Fabric with:@[CrashlyticsKit]];
#endif
Delwin answered 17/4, 2015 at 7:50 Comment(1)
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 presentConners
E
5

If you use Swift, this woud work:

#if !DEBUG
    Fabric.with([Crashlytics.self])
#endif
Etam answered 28/9, 2018 at 5:55 Comment(0)
H
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
Haply answered 17/4, 2015 at 8:14 Comment(0)
M
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
Mob answered 2/1, 2019 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.