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

  3. 执行: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

  3. 新建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.
      // 想要什么配置自己加
      }];
      }
  4. 使用插件参考: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
相关推荐
泉木4 小时前
KVC 详解 —— Key-Value Coding 完全指南
ios·swift
sweet丶5 小时前
现有基础上增加设备生物识别登录的一个技术方案
ios
阳光先做6 小时前
uniapp打包鸿蒙安装包问题
uni-app
嵌入式×边缘AI:打怪升级日志9 小时前
转换模块(十二):实现 RGB 转 RGB + 项目整合与上机实验
开发语言·ios·swift
唐诺9 小时前
IOS学习路线计划
ios
for_ever_love__9 小时前
UI学习:无限轮播视图
学习·ui·ios·objective-c
MonkeyKing10 小时前
iOS Block 底层深度解析:结构、变量捕获、copy逻辑与循环引用本质
ios
MonkeyKing10 小时前
iOS ARC 本质:__strong / __weak / __unsafe_unretained / __autoreleasing 深度解析
ios
humors22111 小时前
全平台日常使用的国外应用
android·ios·app·安卓·应用·国外