集成到sentry官网平台上的步骤:
1、注册,登录
网址:https://sentry.io/
注册一个账号
![](https://img.haomeiwen.com/i5720820/6904e3bc1044440d.png)
2、创建一个项目(project)
![](https://img.haomeiwen.com/i5720820/05827d0798b1a08a.png)
3、iOS客户端pod进sentry
在项目Podfile文件中:
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '4.1.0'
执行,引入sentry第三方
pod install
4、配置
在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法中实现如下代码
OC
NSError *error = nil;
SentryClient *client = [[SentryClient alloc] initWithDsn:@"https://905b6c2bd0784285ae87895fe526d4f2@sentry.io/1306735" didFailWithError:&error];
SentryClient.sharedClient = client;
[SentryClient.sharedClient startCrashHandlerWithError:&error];
if (nil != error) {
NSLog(@"%@", error);
Swift
do {
Client.shared = try Client(dsn: "https://905b6c2bd0784285ae87895fe526d4f2@sentry.io/1306735")
try Client.shared?.startCrashHandler()
} catch let error {
print("\(error)")
}
重点来了:
配置的时候需要填一个dsn,这个在哪里找呢?
![](https://img.haomeiwen.com/i5720820/1d4cd080d2806893.png)
![](https://img.haomeiwen.com/i5720820/b78ca5ce4540e235.png)
复制,粘贴到代码里即可。
5、上传dsym文件
这是个大坑😂
这里我使用官网推荐的fastlane上传
如果你项目里没有使用fastlane,可以看这篇文章,很详细,一步一步跟着做就好了点这里
-
分两种:with Bitcode, without Bitcode
怎么看呢?
![](https://img.haomeiwen.com/i5720820/6fb4d08ebb780aba.png)
我这里设为NO,即:without Bitcode
-
对于without Bitcode
修改fastlane文件夹下的
![](https://img.haomeiwen.com/i5720820/7a038bb363a9bd51.png)
添加如下代码
desc "上传dysm文件"
lane :uploadsydm do
#increment_build_number
#2.1编译 选择scheme和功能
gym
sentry_upload_dsym(
auth_token: '自己的token',
org_slug: '创建项目时的组织名称',
project_slug: '项目名称',
)
end
![](https://img.haomeiwen.com/i5720820/f30c2f8e9a1c9384.png)
重点又来了!
这三个参数从哪里找?
点击设置
![](https://img.haomeiwen.com/i5720820/01578ed01f7ee98e.png)
看到了两个参数:
![](https://img.haomeiwen.com/i5720820/89e34921e0638d76.png)
那token呢?
![](https://img.haomeiwen.com/i5720820/1f6aa6073ef7b812.png)
这时候就拿到了这三个参数了
-
对于with Bitcode
参数获取方式一致
lane :upload_symbols do
download_dsyms
upload_symbols_to_sentry(
auth_token: '...',
org_slug: '...',
project_slug: '...',
)
end
6、该上传了
-
cd到项目根目录
![](https://img.haomeiwen.com/i5720820/f4fb6692aa493ad1.png)
-
先执行:
fastlane add_plugin sentry
这是因为upload_symbols_to_sentry被废弃了,使用新的函数sentry_upload_dsym代替
![](https://img.haomeiwen.com/i5720820/04b7ff9ea9dea63d.png)
再执行:
fastlane (函数名)
//例如我的
fastlane uploadsydm
-
这时候会报如下错误
![](https://img.haomeiwen.com/i5720820/ed77dcf9bd3a25eb.png)
这是因为需要安装sentry-cli
解决:
执行 brew install getsentry/tools/sentry-cli
或者
curl -sL https://sentry.io/get-cli/ | bash
7、上传成功,在这里可以看到
![](https://img.haomeiwen.com/i5720820/f6f1c98152b3219b.png)
8、使用
自己写一个崩溃
运行一次崩溃,在运行一次就会上传崩溃日志
即可查看
![](https://img.haomeiwen.com/i5720820/bb87353f6fbfe468.png)
![](https://img.haomeiwen.com/i5720820/f600e53688490408.png)
参考:
https://docs.fastlane.tools/actions/upload_symbols_to_sentry/
https://docs.sentry.io/clients/cocoa/dsym/#dsym-without-bitcode
https://www.jianshu.com/p/b4334dec2f37
网友评论