集成到sentry官網(wǎng)平臺上的步驟:
1、注冊,登錄
網(wǎng)址:https://sentry.io/
注冊一個賬號

2、創(chuàng)建一個項目(project)

3、iOS客戶端pod進sentry
在項目Podfile文件中:
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '4.1.0'
執(zhí)行,引入sentry第三方
pod install
4、配置
在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法中實現(xiàn)如下代碼
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,這個在哪里找呢?


復制,粘貼到代碼里即可。
5、上傳dsym文件
這是個大坑??
這里我使用官網(wǎng)推薦的fastlane上傳
如果你項目里沒有使用fastlane,可以看這篇文章,很詳細,一步一步跟著做就好了點這里
-
分兩種:with Bitcode, without Bitcode
怎么看呢?

我這里設為NO,即:without Bitcode
-
對于without Bitcode
修改fastlane文件夾下的

添加如下代碼
desc "上傳dysm文件"
lane :uploadsydm do
#increment_build_number
#2.1編譯 選擇scheme和功能
gym
sentry_upload_dsym(
auth_token: '自己的token',
org_slug: '創(chuàng)建項目時的組織名稱',
project_slug: '項目名稱',
)
end

重點又來了!
這三個參數(shù)從哪里找?
點擊設置

看到了兩個參數(shù):

那token呢?

這時候就拿到了這三個參數(shù)了
-
對于with Bitcode
參數(shù)獲取方式一致
lane :upload_symbols do
download_dsyms
upload_symbols_to_sentry(
auth_token: '...',
org_slug: '...',
project_slug: '...',
)
end
6、該上傳了
-
cd到項目根目錄

-
先執(zhí)行:
fastlane add_plugin sentry
這是因為upload_symbols_to_sentry被廢棄了,使用新的函數(shù)sentry_upload_dsym代替

再執(zhí)行:
fastlane (函數(shù)名)
//例如我的
fastlane uploadsydm
-
這時候會報如下錯誤

這是因為需要安裝sentry-cli
解決:
執(zhí)行 brew install getsentry/tools/sentry-cli
或者
curl -sL https://sentry.io/get-cli/ | bash
7、上傳成功,在這里可以看到

8、使用
自己寫一個崩潰
運行一次崩潰,在運行一次就會上傳崩潰日志
即可查看


參考:
https://docs.fastlane.tools/actions/upload_symbols_to_sentry/
https://docs.sentry.io/clients/cocoa/dsym/#dsym-without-bitcode
http://www.itdecent.cn/p/b4334dec2f37