How to integrate Crashlytics into an iOS framework

2019-01-26 12:45发布

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?

3条回答
爷、活的狠高调
2楼-- · 2019-01-26 13:11

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.

查看更多
放荡不羁爱自由
3楼-- · 2019-01-26 13:12

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)
});
查看更多
迷人小祖宗
4楼-- · 2019-01-26 13:28

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.

查看更多
登录 后发表回答