uniapp ios app以framwork形式接入sentry

一、下载Sentry

  1. mac终端输入:vim Podfile
  2. 修改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
  1. 执行:pod install下载sentry依赖

二、配置sentry

  1. 把开发教程的东西配置完:https://nativesupport.dcloud.net.cn/NativePlugin/course/ios.html
  2. 新建SentryModule.h文件,内容如下:
#import <Foundation/Foundation.h>
// 引入 DCUniModule.h 头文件
#import "DCUniModule.h"

@interface SentryModule: DCUniModule

@end
  1. 新建SentryModule.m文件,内容如下:
#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.
        // 想要什么配置自己加
    }];
}
  1. 使用插件参考:https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios.html

ps: 其他报错

报错’Sentry/Sentry.h’ file not found 解决方法:

  1. pod install 会生成一个 .xcworkspace 文件,如果没有就是安装失败了;
  2. 在 Xcode 中打开项目时,应该打开这个 .xcworkspace 文件,而不是原始的 .xcodeproj 文件。否则,Xcode 将无法找到通过 CocoaPods 安装的依赖框架,包括 Sentry。

打包时报错 No type named “terminate_handler" in namespace ‘std’ 总结解决方法:参考此贴

  1. 升级xcode到16.0或以上
  2. sentry安装8.32.0以上,我安装的是8.40.1
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值