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
相关推荐
CocoaKier11 分钟前
Facebook登录的这条红色警告,我终于搞明白了,真是反人类设计!
ios·facebook
不法3 小时前
uniapp map地图导航/地图路线
前端·vue.js·uni-app
沐风___7 小时前
iOS 崩溃收集实战:从「只看到次数、看不到原因」到 Sentry 完整集成
ios·sentry
listening7778 小时前
HarmonyOS 6.1 跨端实战:用ArkUI-X把电商App同时跑在Android/iOS上
android·ios·harmonyos
Tyler_19 小时前
iOS PlayWright mcp server
前端·ios·ai编程
淡淡的幼稚1 天前
【YFIOs】从传感芯片到表格曲线
uni-app·.net
宠友信息1 天前
多端即时通讯源码技术实践,Redis路由、MySQL持久化与Socket接入
spring boot·websocket·mysql·uni-app
宠友信息1 天前
Spring Boot与异步审核构建仿小红书源码内容发布全流程
java·数据库·spring boot·redis·mysql·oracle·uni-app
蜡台1 天前
uniapp vue2 转 vue3
前端·javascript·uni-app·vue3·vue2
2501_916008891 天前
iOS 证书管理最佳实践 从创建到续期的完整指南
android·ios·小程序·https·uni-app·iphone·webview