简体   繁体   English

如何将Crashlytics集成到iOS框架目标中?

[英]How to integrate Crashlytics into an iOS framework target?

I have an iOS framework target, and I need integrate Crash reporting system for it. 我有一个iOS框架目标,我需要为它集成Crash报告系统。

So Crashlytics looks good, but 所以Crashlytics看起来不错,但是

This Xcode project does not have any Mac or iOS targets 此Xcode项目没有任何Mac或iOS目标

So, is there any way to integrate Crashlytics directly into iOS framework? 那么,有没有办法将Crashlytics直接集成到iOS框架中?

Thanks Mike Bonnell for your comment here , which says: 感谢Mike Bonnell这里的评论 ,其中说:

Sure, our SDK only supports being initialized once. 当然,我们的SDK仅支持初始化一次。 Being initialized in a framework and application would cause a conflict. 在框架和应用程序中初始化会导致冲突。 You and the app developer would have different API keys and there is no way to ask the app developer to give permission to your SDK to share stack traces from their code with your framework. 您和应用程序开发人员将拥有不同的API密钥,并且无法让应用程序开发人员授予您的SDK权限,以便与您的框架共享代码中的堆栈跟踪。 Including us in your framework will cause issues for your framework and anyone that uses it, so that's why I said don't include us! 在我们的框架中包含我们将导致您的框架和使用它的任何人的问题,所以这就是为什么我说不包括我们! Totally understand that SDK developers would love to see this supported. 完全理解SDK开发人员希望看到这种支持。

There is a solution here that allows your lib users to utilize crashlytics for logging. 这里有一个解决方案,允许您的lib用户使用crashlytics进行日志记录。

Your lib can provide a default log function that calls NSLog or Print or what ever mechanism you want. 您的lib可以提供一个默认的日志功能,可以调用NSLog或Print或您想要的任何机制。 But also have your library provide a mechanism to override the print method used. 但也有你的库提供一种机制来覆盖使用的打印方法。

For example, imagine you have a Logger class defined in your library: 例如,假设您在库中定义了Logger类:

public class Logger {
  private static var printer: (message: String) -> Void = nil
  public static func setPrinter(newPrinter: (message: String) -> Void) {
    Logger.printer = newPrinter
  }

  debug(format: String, ...) {
      // convert params into a single formatted:String, then ...
      if(Logger.printer != nil) {
          Logger.printer(message: formatted)
      } else {
          print(formatted)
          // or
          NSLog(formatted)
      }
  }
}

Now, when people use your library they will get default printing you implement. 现在,当人们使用您的库时,他们将获得您实施的默认打印。 But, if they have their own logging solution, like crashlytics they can override it like so: 但是,如果他们有自己的日志记录解决方案,比如crashlytics他们可以像这样覆盖它:

// in their App code
Logger.setPrinter((message:String) -> Void {
  CLSNSLog(message)
});

Follow the below steps provided in the link to integrate Crashlytics. 按照链接中提供的以下步骤集成Crashlytics。

Fabric Integration 面料整合

The most powerful, yet lightest weight crash reporting solution. 最强大,最轻量级的重量损失报告解决方案。 Spend less time finding and more time fixing crashes. 花费更少的时间寻找和更多的时间来解决崩溃问题。 Named the #1 performance SDK on both iOS and Android, Crashlytics provides deep and actionable insights, even the exact line of code your app crashed on. 在iOS和Android上被命名为#1性能SDK,Crashlytics提供深入且可操作的见解,甚至是应用程序崩溃的确切代码行。

While Crashlytics gives you powerful crash reporting, with one additional click you can enable real-time analytics that help you understand what's happening in your app. 虽然Crashlytics为您提供了强大的崩溃报告功能,但只需再点击一次,您就可以启用实时分析,帮助您了解应用中发生的情况。 Fabric's analytics engine provides insights into your core goals, such as growth, retention, and engagement. Fabric的分析引擎可以深入了解您的核心目标,例如增长,保留和参与度。 Finally, analytics you don't need to analyze. 最后,您不需要分析分析。

Hope it helps. 希望能帮助到你。

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

相关问题 如何将Crashlytics集成到iOS框架项目中? - How to integrate Crashlytics into an iOS framework project? Crashlytics登录iOS框架 - Crashlytics logs in ios framework 如何为 Flutter 应用程序的 iOS 部分集成 Firebase Crashlytics? - How to integrate Firebase Crashlytics for iOS part of Flutter app? 如何将DBAccess框架集成到另一个框架(iOS) - How to integrate DBAccess Framework in another framework (iOS) 如何将Crashlytics与静态库集成 - How to integrate Crashlytics with static library 如何将 Crashlytics 与 React Native 应用程序集成 - How to Integrate Crashlytics with React Native app 如何在共享扩展中集成Fabric / Crashlytics - How to integrate Fabric/Crashlytics in an shared extension 如何使用自己的框架在iOS应用中正确设置Crashlytics,以便从框架中获取日志和密钥? - How to correctly set up Crashlytics in iOS app with own framework in order to get logs and keys from the framework? 在没有 PODS 的 iOS 项目中集成 Firebase Crashlytics(测试版)SDK - Integrate Firebase Crashlytics (beta) SDK in iOS project without PODS 如何在新的iOS8框架目标中链接Cocoapods生成的框架 - How to link an framework generated by Cocoapods in a new iOS8 framework target
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM