集成 Crashlytics 的步骤:-
1.添加下面的可可豆荚
pod 'Fabric'
pod 'Crashlytics'
2.将运行脚本添加到构建阶段(对于此步骤,您必须登录 Fabric 才能获取 API 密钥)
"${PODS_ROOT}/Fabric/run" 8252525b24e2d6fagsdg101ea7faf49edefa84ff3ec342b0dgsdrergadc2bd8agsdg50671jhga2ee8c017ddgsdg33fbbb
3.将您的API密钥添加到info.plist文件中
<key>Fabric</key>
<dict>
<key>APIKey</key>
<string>your_key</string>
<key>Kits</key>
<array>
<dict>
<key>KitInfo</key>
<dict/>
<key>KitName</key>
<string>Crashlytics</string>
</dict>
</array>
</dict>
4.在AppDelegate文件中添加以下代码
AppDelegate.h:-
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>
AppDelegate.m:-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Fabric with:@[[Crashlytics class]]]
}
5.对于强制崩溃,请在视图控制器的任何按钮单击事件上编写以下代码,不能写入应用程序委托文件
[[Crashlytics sharedInstance] crash];
6.更改构建设置:
click on project target >> Build setting >> Chnage value of “Debug information Format” set it to “DWARF with dSYM file”
click on project >> Build setting >> Chnage value of “Debug information Format” set it to “DWARF with dSYM file”
7.如何使应用程序崩溃
Xcode's debugger prevents us from processing crash reports.
To make sure a crash is reported during your simulator testing:
⁃ Launch simulator (Run your project and install app in simulator)
⁃ Press stop (stop from Xcode )
⁃ Launch your app and force a crash (Now do not run project, just open simulator and launch your app from simulator and press button that u write code for crash ` [[Crashlytics sharedInstance] crash];`)
⁃ Relaunch the app from simulator (again run app from simulator not from Xcode project)
⁃ See the crash report in the web dashboard