How to integrate Crashlytics into an iOS framework target?

*爱你&永不变心* 提交于 2019-11-26 21:51:37

问题


I have an iOS framework target, and I need integrate Crash reporting system for it.

So Crashlytics looks good, but

This Xcode project does not have any Mac or iOS targets

So, is there any way to integrate Crashlytics directly into iOS framework?


回答1:


Thanks Mike Bonnell for your comment here, which says:

Sure, our SDK only supports being initialized once. 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. 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.




回答2:


There is a solution here that allows your lib users to utilize crashlytics for logging.

Your lib can provide a default log function that calls NSLog or Print or what ever mechanism you want. 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:

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:

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



回答3:


Follow the below steps provided in the link to integrate 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.

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. Fabric's analytics engine provides insights into your core goals, such as growth, retention, and engagement. Finally, analytics you don't need to analyze.

Hope it helps.



来源:https://stackoverflow.com/questions/44155649/how-to-integrate-crashlytics-into-an-ios-framework-target

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!