一、下載Sentry
- mac終端輸入:
vim Podfile
- 修改Podfile:
platform :ios, '11.0'
target 'YourApp' do
use_frameworks! # This is important
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '8.40.1'
end
- 執(zhí)行:
pod install
下載sentry依賴
二侨嘀、配置sentry
- 把開(kāi)發(fā)教程的東西配置完:https://nativesupport.dcloud.net.cn/NativePlugin/course/ios.html
- 新建SentryModule.h文件型宝,內(nèi)容如下:
#import <Foundation/Foundation.h>
// 引入 DCUniModule.h 頭文件
#import "DCUniModule.h"
@interface SentryModule: DCUniModule
@end
- 新建SentryModule.m文件八匠,內(nèi)容如下:
#import "SentryModule.h"
#import <Sentry/Sentry.h>
@implementation SentryModule
UNI_EXPORT_METHOD_SYNC(@selector(init:))
- (void)init:(NSDictionary *)appOpt
{
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = appOpt[@"dsn"];
options.debug = YES; // Enabled debug when first installing is always helpful
// Enable tracing to capture 100% of transactions for tracing.
// Use 'options.tracesSampleRate' to set the sampling rate.
// 想要什么配置自己加
}];
}
ps: 其他報(bào)錯(cuò)
報(bào)錯(cuò)'Sentry/Sentry.h' file not found 解決方法:
- pod install 會(huì)生成一個(gè) .xcworkspace 文件,如果沒(méi)有就是安裝失敗了趴酣;
- 在 Xcode 中打開(kāi)項(xiàng)目時(shí)梨树,應(yīng)該打開(kāi)這個(gè) .xcworkspace 文件,而不是原始的 .xcodeproj 文件岖寞。否則抡四,Xcode 將無(wú)法找到通過(guò) CocoaPods 安裝的依賴框架,包括 Sentry。
打包時(shí)報(bào)錯(cuò) No type named “terminate_handler" in namespace 'std' 總結(jié)解決方法:參考此貼
- 升級(jí)xcode到
16.0
或以上 - sentry安裝
8.32.0
以上指巡,我安裝的是8.40.1