如何使用标志禁用Crashlytics iOS库? [英] How to disable Crashlytics iOS library using a flag?

查看:49
本文介绍了如何使用标志禁用Crashlytics iOS库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS的最新Crashlytics库.我希望使用单个标志来禁用crashlytics.我该怎么办?

I am using latest Crashlytics library for iOS. I am looking to disable crashlytics using a single flag. How can I do that?

PS:我没有按照新的SDK集成准则使用set API密钥方法. (使用MAC应用程序集成)

PS: I am not using set API key method as per new SDK integration guidelines. (integrated using MAC app)

推荐答案

您是要阻止Crashlytics运行还是要完全阻止SDK编译?

Are you trying to prevent Crashlytics from running, or prevent the SDK from getting compiled in at all?

要阻止它运行,您不能进行Crashlyitcs调用来使它继续运行,通常是在您的应用程序委托中完成.

To prevent it from running, you can not make the Crashlyitcs call to get it going, generally done in your app delegate.

例如,如果您在Fabric之前使用Crashlytics,只需注释掉以下行:

For example, if you're using Crashlytics before Fabric, just comment out the following line:

[Crashlytics startWithAPIKey:<your key>];

如果您使用的是Fabric,则需要注释掉以下行:

If you are using Fabric, you'd want to comment out the following line:

[Fabric with:@[CrashlyticsKit]];

如果您正在使用其他Fabric服务,请从Fabric服务中删除"CrashlyticsKit"以用于启动.因此,例如,您想要更改:

If you're using another Fabric service, remove 'CrashlyticsKit' from the services for Fabric to launch with. So for example, you'd want to change:

[Fabric with:@[TwitterKit, CrashlyticsKit]];

收件人:

[Fabric with:@[TwitterKit]];

由于您希望使用标志来完成此操作,因此有多种方法可以解决此问题,一种方法是使用处理器宏.例如,如果您只是想在XCode中运行时禁用Crashlytics,则可以使用DEBUG(一种在XCode项目中默认设置为1的预处理器宏),方法如下:

Since you want this done with a flag, there are a number of ways to go about this, One way is to use a processor macro. For example, if you're just trying to disable Crashlytics while running in XCode, you can use DEBUG, a preprocessor macro that's set to 1 in XCode projects by default, in the following way:

#if DEBUG == 0 [Crashlytics startWithAPIKey:<your key>]; #endif

#if DEBUG == 0 [Crashlytics startWithAPIKey:<your key>]; #endif

通过在XCode中打开项目文件(.xcodeproj),可以为任意上下文添加自己的预处理器宏,选择目标,选择构建设置"选项卡,滚动到"Apple LLVM 6.0-预处理" "部分,然后更改预处理器宏"下的条目.您可以根据需要将它们添加到任何项目配置中.

You can add your own preprocessor macros for whatever contexts you'd like by opening your project file (.xcodeproj) in XCode, select your target, select the "Build Settings" tab, scroll to the "Apple LLVM 6.0 - Preprocessing" section, and change the entries under "Preprocessor Macros". You can add them for any project configuration, however you'd like.

这篇关于如何使用标志禁用Crashlytics iOS库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆