首页
/ Airbrake iOS 项目技术文档

Airbrake iOS 项目技术文档

2024-12-20 09:51:19作者:宣聪麟

1. 安装指南

直接从源代码安装

  1. Airbrake 文件夹拖到你的项目中,并确保勾选了“Copy Items”和“Create Groups”。
  2. SystemConfiguration.framework 添加到你的项目中。
  3. CrashReporter.frameworkAirbrake 文件夹中添加到你的项目中。

使用 CocoaPods 安装

在你的 Podfile 中添加以下行:

pod 'Airbrake-iOS'

然后运行 pod install

2. 项目的使用说明

项目简介

Airbrake iOS/Mac OS Notifier 旨在为开发者提供应用程序中问题的即时通知。只需几行代码和几个额外的文件,你的应用程序就可以在遇到崩溃或异常时自动向 Airbrake 报告。这些报告会直接发送到 Airbrake,你可以在其中查看诸如回溯、设备类型、应用程序版本等信息。

信号处理

Notifier 处理所有未处理的异常以及以下 Unix 信号:

  • SIGABRT
  • SIGBUS
  • SIGFPE
  • SIGILL
  • SIGSEGV
  • SIGTRAP

符号化

为了在崩溃时正确符号化调用栈,使用 Notifier 构建的应用程序不应在编译时剥离符号信息。如果未按推荐设置这些选项,你的二进制文件中的帧将显示为十六进制返回地址,而不是可读的字符串。这些十六进制返回地址可以使用 atos 进行符号化。

版本控制

Airbrake 支持报告通知的版本下限。你可以在项目设置中指定最低应用程序版本,使用语义版本控制进行比较。

3. 项目API使用文档

在 Swift 中作为框架运行

  1. Podfile 中添加以下内容:

    use_frameworks!
    pod 'Airbrake-iOS'
    
  2. AppDelegate 中导入 Airbrake_iOS

    import Airbrake_iOS
    
  3. AppDelegateapplication(_:didFinishLaunchingWithOptions:) 方法中设置 ABNotifier

    ABNotifier.start(
      withAPIKey: "YOUR_API_KEY",
      projectID: "Your_Product_ID",
      environmentName: ABNotifierAutomaticEnvironment,
      useSSL: true
    )
    

在 Swift 中作为静态库运行

  1. 创建一个桥接头文件 [ProjectName]_Bridging_Header.h,并在其中添加 ABNotifier

    #ifndef [ProjectName]_Bridging_Header
    #define [ProjectName]_Bridging_Header
    #import "ABNotifier.h"
    #endif
    
  2. 在项目构建设置中,将桥接头文件添加到 Objective-C Bridging Header

  3. AppDelegate 中设置 ABNotifier

    ABNotifier.start(
      withAPIKey: "YOUR_API_KEY",
      projectID: "Your_Product_ID",
      environmentName: ABNotifierAutomaticEnvironment,
      useSSL: true
    )
    

在 Objective-C 中运行

  1. AppDelegate 中导入 ABNotifier

    #import "ABNotifier.h"
    
  2. application:didFinishLaunchingWithOptions: 方法中启动 Notifier:

    [ABNotifier startNotifierWithAPIKey:@"YOUR_API_KEY"
                              projectID:@"Your_Product_ID"
                        environmentName:ABNotifierAutomaticEnvironment
                               delegate:self];
    

4. 项目安装方式

直接从源代码安装

  1. Airbrake 文件夹拖到你的项目中,并确保勾选了“Copy Items”和“Create Groups”。
  2. SystemConfiguration.framework 添加到你的项目中。
  3. CrashReporter.frameworkAirbrake 文件夹中添加到你的项目中。

使用 CocoaPods 安装

在你的 Podfile 中添加以下行:

pod 'Airbrake-iOS'

然后运行 pod install

通过以上步骤,你可以成功安装并使用 Airbrake iOS Notifier 来监控应用程序中的崩溃和异常。

登录后查看全文
热门项目推荐