简体   繁体   English

如何在开发过程中为 iOS 禁用 Crashlytics?

[英]How to disable Crashlytics for iOS during development?

Is there any way to disable crash reporting for Ad-Hoc builds?有什么方法可以禁用 Ad-Hoc 构建的崩溃报告? 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我使用的是 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.编辑:我根本不想禁用 Fabric,我只需要 Ad-Hoc 和 Release 构建的自动配置。

I think you can try this :我想你可以试试这个:

#ifndef DEBUG
 [Fabric with:@[CrashlyticsKit]];
#endif

If you use Swift, this woud work:如果您使用 Swift,这将起作用:

#if !DEBUG
    Fabric.with([Crashlytics.self])
#endif

Development builds are also DEBUG builds, You are probably meaning Ad-Hoc builds.开发构建也是DEBUG构建,您可能指的是临时构建。 Since the release and Ad-Hoc build use the same configuration you will not be able to tell them apart.由于发行版和 Ad-Hoc 构建使用相同的配置,您将无法区分它们。

You bets option is to create a new configuration for the AppStore.您打赌的选项是为 AppStore 创建一个新配置。 For this configuration add a Preprocessor Macro , Like FABRIC=1对于这个配置添加一个Preprocessor Macro ,比如FABRIC=1

Then in you build code:然后在你构建代码:

#ifdef FABRIC
    [Fabric with:@[CrashlyticsKit]];
#endif

For Swift, Add this key to plist and set it 'NO'.对于 Swift,将此键添加到 plist 并将其设置为“NO”。

firebase_crashlytics_collection_enabled

After this, based on user-defined variable in Build Settings, you can configure this.在此之后,您可以根据 Build Settings 中用户定义的变量进行配置。

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

To disable firebase crashlytics for debug mode in swift:要在 swift 中为调试模式禁用 firebase crashlytics:

    #if DEBUG
        Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(false)
    #endif

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM