sentry-cocoa-sdk
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSentry Cocoa SDK
Sentry Cocoa SDK
Opinionated wizard that scans your Apple project and guides you through complete Sentry setup.
这是一个带有预设规则的向导,可扫描你的Apple项目并引导你完成完整的Sentry设置。
Invoke This Skill When
何时调用此技能
- User asks to "add Sentry to iOS/macOS/tvOS" or "set up Sentry" in an Apple app
- User wants error monitoring, tracing, profiling, session replay, or logging in Swift/ObjC
- User mentions ,
sentry-cocoa, or the Apple/iOS Sentry SDKSentrySDK - User wants to monitor crashes, app hangs, watchdog terminations, or performance
Note: SDK versions and APIs below reflect Sentry docs at time of writing (sentry-cocoa 9.5.1). Always verify against docs.sentry.io/platforms/apple/ before implementing.
- 用户要求“为iOS/macOS/tvOS添加Sentry”或在Apple应用中“设置Sentry”
- 用户希望在Swift/ObjC中实现错误监控、追踪、性能分析、会话重放或日志功能
- 用户提到、
sentry-cocoa或Apple/iOS Sentry SDKSentrySDK - 用户希望监控崩溃、应用挂起、看门狗终止或性能
注意: 以下SDK版本和API反映了编写时Sentry文档的内容(sentry-cocoa 9.5.1)。 在实施前,请务必对照docs.sentry.io/platforms/apple/进行验证。
Phase 1: Detect
阶段1:检测
Run these commands to understand the project before making any recommendations:
bash
undefined在提出任何建议之前,运行以下命令来了解项目情况:
bash
undefinedCheck existing Sentry dependency
检查现有的Sentry依赖
grep -i sentry Package.swift Podfile Cartfile 2>/dev/null
grep -i sentry Package.swift Podfile Cartfile 2>/dev/null
Detect UI framework (SwiftUI vs UIKit)
检测UI框架(SwiftUI vs UIKit)
grep -rE "@main|struct.App.:.App" --include=".swift" . 2>/dev/null | head -5
grep -rE "AppDelegate|UIApplicationMain" --include="*.swift" . 2>/dev/null | head -5
grep -rE "@main|struct.App.:.App" --include=".swift" . 2>/dev/null | head -5
grep -rE "AppDelegate|UIApplicationMain" --include="*.swift" . 2>/dev/null | head -5
Detect platform and deployment targets
检测平台和部署目标
grep -E "platforms:|.iOS|.macOS|.tvOS|.watchOS|.visionOS" Package.swift 2>/dev/null
grep -E "platform :ios|platform :osx|platform :tvos|platform :watchos" Podfile 2>/dev/null
grep -E "platforms:|.iOS|.macOS|.tvOS|.watchOS|.visionOS" Package.swift 2>/dev/null
grep -E "platform :ios|platform :osx|platform :tvos|platform :watchos" Podfile 2>/dev/null
Detect logging
检测日志工具
grep -rE "import OSLog|os.log|CocoaLumberjack|DDLog" --include="*.swift" . 2>/dev/null | head -5
grep -rE "import OSLog|os.log|CocoaLumberjack|DDLog" --include="*.swift" . 2>/dev/null | head -5
Detect companion backend
检测配套后端服务
ls ../backend ../server ../api 2>/dev/null
ls ../go.mod ../requirements.txt ../Gemfile ../package.json 2>/dev/null
**What to note:**
- Is `sentry-cocoa` already in `Package.swift` or `Podfile`? If yes, skip to Phase 2 (configure features).
- SwiftUI (`@main App` struct) or UIKit (`AppDelegate`)? Determines init pattern.
- Which Apple platforms? (Affects which features are available — see Platform Support Matrix.)
- Existing logging library? (Enables structured log capture.)
- Companion backend? (Triggers Phase 4 cross-link for distributed tracing.)
---ls ../backend ../server ../api 2>/dev/null
ls ../go.mod ../requirements.txt ../Gemfile ../package.json 2>/dev/null
**需要注意的点:**
- `sentry-cocoa`是否已在`Package.swift`或`Podfile`中?如果是,直接跳到阶段2(配置功能)。
- 是SwiftUI(`@main App`结构体)还是UIKit(`AppDelegate`)?这决定了初始化方式。
- 目标是哪些Apple平台?(会影响可用功能——参见平台支持矩阵。)
- 是否有现有的日志库?(可启用结构化日志捕获。)
- 是否有配套后端服务?(会触发阶段4的跨链路配置以实现分布式追踪。)
---Phase 2: Recommend
阶段2:推荐
Based on what you found, present a concrete recommendation. Don't ask open-ended questions — lead with a proposal:
Recommended (core coverage):
- ✅ Error Monitoring — always; crash reporting, app hangs, watchdog terminations, NSError/Swift errors
- ✅ Tracing — always for apps; auto-instruments app launch, network, UIViewController, file I/O, Core Data
- ✅ Profiling — production apps; continuous profiling with minimal overhead
Optional (enhanced observability):
- ⚡ Session Replay — user-facing apps; ⚠️ disabled by default on iOS 26+ (Liquid Glass rendering)
- ⚡ Logging — when structured log capture is needed
- ⚡ User Feedback — apps that want crash/error feedback forms from users
Not available for Cocoa:
- ❌ Metrics — use custom spans instead
- ❌ Crons — backend only
- ❌ AI Monitoring — JS/Python only
Recommendation logic:
| Feature | Recommend when... |
|---|---|
| Error Monitoring | Always — non-negotiable baseline |
| Tracing | Always for apps — rich auto-instrumentation out of the box |
| Profiling | Production apps where performance matters |
| Session Replay | iOS only user-facing apps (check iOS 26+ caveat; not tvOS/macOS/watchOS/visionOS) |
| Logging | Existing |
| User Feedback | Apps wanting in-app bug reports with screenshots |
Propose: "I recommend Error Monitoring + Tracing + Profiling. Want me to also add Session Replay and Logging?"
根据检测结果,给出具体的建议。不要提出开放式问题,直接给出方案:
推荐(核心覆盖):
- ✅ 错误监控 — 必选;包含崩溃报告、应用挂起、看门狗终止、NSError/Swift错误捕获
- ✅ 追踪 — 应用必选;自动检测应用启动、网络请求、UIViewController、文件I/O、Core Data等环节
- ✅ 性能分析 — 生产环境应用必选;低开销的持续性能分析
可选(增强可观测性):
- ⚡ 会话重放 — 面向用户的应用可选;⚠️ iOS 26+默认禁用(Liquid Glass渲染限制)
- ⚡ 日志 — 需要结构化日志捕获时可选
- ⚡ 用户反馈 — 希望收集用户崩溃/错误反馈表单的应用可选
Cocoa平台不支持的功能:
- ❌ 指标 — 请使用自定义span替代
- ❌ 定时任务监控 — 仅后端支持
- ❌ AI监控 — 仅JS/Python支持
推荐逻辑:
| 功能 | 推荐场景 |
|---|---|
| 错误监控 | 必选 — 基础监控能力,不可或缺 |
| 追踪 | 应用必选 — 开箱即用的丰富自动检测能力 |
| 性能分析 | 对性能有要求的生产环境应用 |
| 会话重放 | 仅iOS 面向用户的应用(注意iOS 26+限制;tvOS/macOS/watchOS/visionOS不支持) |
| 日志 | 已使用 |
| 用户反馈 | 希望提供应用内报错反馈表单的应用 |
建议话术:"我推荐启用错误监控 + 追踪 + 性能分析。是否需要同时添加会话重放和日志功能?"
Phase 3: Guide
阶段3:指导
Install
安装
Option 1 — Sentry Wizard (recommended): Walks you through login, org/project selection, and auth token setup interactively. Then installs the SDK, updates AppDelegate, adds dSYM/debug symbol upload build phases, and configures everything automatically.
bash
brew install getsentry/tools/sentry-wizard && sentry-wizard -i iosOption 2 — Swift Package Manager: File → Add Packages → enter:
https://github.com/getsentry/sentry-cocoa.gitOr in :
Package.swiftswift
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "9.5.1"),SPM Products — choose exactly one per target:
| Product | Use Case |
|---|---|
| Recommended — static framework, fast app start |
| Dynamic framework alternative |
| SwiftUI view performance tracking ( |
| watchOS, app extensions, CLI tools |
⚠️ Xcode allows selecting multiple products — choose only one.
Option 3 — CocoaPods:
ruby
platform :ios, '11.0'
use_frameworks!
target 'YourApp' do
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '9.5.1'
endKnown issue (Xcode 14+): Sandboxerror → Target Settings → "Enable User Script Sandbox" →rsync.samba.NO
选项1 — Sentry Wizard(推荐): 交互式引导你完成登录、组织/项目选择和授权令牌设置。随后自动安装SDK、更新AppDelegate、添加dSYM/调试符号上传构建阶段,并完成所有配置。
bash
brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios选项2 — Swift Package Manager: 点击File → Add Packages → 输入:
https://github.com/getsentry/sentry-cocoa.git或在中添加:
Package.swiftswift
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "9.5.1"),SPM产品选择 — 每个目标仅选一个:
| 产品 | 使用场景 |
|---|---|
| 推荐 — 静态框架,应用启动速度快 |
| 动态框架替代方案 |
| SwiftUI视图性能追踪( |
| watchOS、应用扩展、CLI工具 |
⚠️ Xcode允许选择多个产品 — 请仅选一个。
选项3 — CocoaPods:
ruby
platform :ios, '11.0'
use_frameworks!
target 'YourApp' do
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '9.5.1'
end已知问题(Xcode 14+): 出现Sandbox错误 → 目标设置 → "Enable User Script Sandbox" → 设置为rsync.samba。NO
Quick Start — Recommended Init
快速开始 — 推荐初始化方式
Full config enabling the most features with sensible defaults. Add before any other code at app startup.
SwiftUI — App entry point:
swift
import SwiftUI
import Sentry
@main
struct MyApp: App {
init() {
SentrySDK.start { options in
options.dsn = ProcessInfo.processInfo.environment["SENTRY_DSN"]
?? "https://examplePublicKey@o0.ingest.sentry.io/0"
options.environment = ProcessInfo.processInfo.environment["SENTRY_ENVIRONMENT"]
options.releaseName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
// Error monitoring (on by default — explicit for clarity)
options.enableCrashHandler = true
options.enableAppHangTrackingV2 = true
options.enableWatchdogTerminationTracking = true
options.attachScreenshot = true
options.attachViewHierarchy = true
options.sendDefaultPii = true
// Tracing
options.tracesSampleRate = 1.0 // lower to 0.2 in high-traffic production
// Profiling (SDK 9.0.0+ API)
options.configureProfiling = {
$0.sessionSampleRate = 1.0
$0.lifecycle = .trace
}
// Session Replay (disabled on iOS 26+ by default — safe to configure)
options.sessionReplay.sessionSampleRate = 1.0
options.sessionReplay.onErrorSampleRate = 1.0
// Logging (SDK 9.0.0+ top-level; use options.experimental.enableLogs in 8.x)
options.enableLogs = true
}
}
var body: some Scene {
WindowGroup { ContentView() }
}
}UIKit — AppDelegate:
swift
import UIKit
import Sentry
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
SentrySDK.start { options in
options.dsn = ProcessInfo.processInfo.environment["SENTRY_DSN"]
?? "https://examplePublicKey@o0.ingest.sentry.io/0"
options.environment = ProcessInfo.processInfo.environment["SENTRY_ENVIRONMENT"]
options.releaseName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
options.enableCrashHandler = true
options.enableAppHangTrackingV2 = true
options.enableWatchdogTerminationTracking = true
options.attachScreenshot = true
options.attachViewHierarchy = true
options.sendDefaultPii = true
options.tracesSampleRate = 1.0
options.configureProfiling = {
$0.sessionSampleRate = 1.0
$0.lifecycle = .trace
}
options.sessionReplay.sessionSampleRate = 1.0
options.sessionReplay.onErrorSampleRate = 1.0
// Logging (SDK 9.0.0+ top-level; use options.experimental.enableLogs in 8.x)
options.enableLogs = true
}
return true
}
}⚠️ SDK initialization must occur on the main thread.
完整配置启用最多功能并使用合理默认值。请在应用启动时的其他代码之前添加。
SwiftUI — App入口:
swift
import SwiftUI
import Sentry
@main
struct MyApp: App {
init() {
SentrySDK.start { options in
options.dsn = ProcessInfo.processInfo.environment["SENTRY_DSN"]
?? "https://examplePublicKey@o0.ingest.sentry.io/0"
options.environment = ProcessInfo.processInfo.environment["SENTRY_ENVIRONMENT"]
options.releaseName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
// 错误监控(默认启用 — 显式配置以明确)
options.enableCrashHandler = true
options.enableAppHangTrackingV2 = true
options.enableWatchdogTerminationTracking = true
options.attachScreenshot = true
options.attachViewHierarchy = true
options.sendDefaultPii = true
// 追踪
options.tracesSampleRate = 1.0 // 高流量生产环境可降低至0.2
// 性能分析(SDK 9.0.0+ API)
options.configureProfiling = {
$0.sessionSampleRate = 1.0
$0.lifecycle = .trace
}
// 会话重放(iOS 26+默认禁用 — 配置无风险)
options.sessionReplay.sessionSampleRate = 1.0
options.sessionReplay.onErrorSampleRate = 1.0
// 日志(SDK 9.0.0+ 顶层配置;8.x版本请使用options.experimental.enableLogs)
options.enableLogs = true
}
}
var body: some Scene {
WindowGroup { ContentView() }
}
}UIKit — AppDelegate:
swift
import UIKit
import Sentry
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
SentrySDK.start { options in
options.dsn = ProcessInfo.processInfo.environment["SENTRY_DSN"]
?? "https://examplePublicKey@o0.ingest.sentry.io/0"
options.environment = ProcessInfo.processInfo.environment["SENTRY_ENVIRONMENT"]
options.releaseName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
options.enableCrashHandler = true
options.enableAppHangTrackingV2 = true
options.enableWatchdogTerminationTracking = true
options.attachScreenshot = true
options.attachViewHierarchy = true
options.sendDefaultPii = true
options.tracesSampleRate = 1.0
options.configureProfiling = {
$0.sessionSampleRate = 1.0
$0.lifecycle = .trace
}
options.sessionReplay.sessionSampleRate = 1.0
options.sessionReplay.onErrorSampleRate = 1.0
// 日志(SDK 9.0.0+ 顶层配置;8.x版本请使用options.experimental.enableLogs)
options.enableLogs = true
}
return true
}
}⚠️ SDK必须在主线程初始化。
For Each Agreed Feature
功能配置指导
Walk through features one at a time. Load the reference file for each, follow its steps, and verify before moving to the next:
| Feature | Reference file | Load when... |
|---|---|---|
| Error Monitoring | | Always (baseline) |
| Tracing | | App launch, network, UIViewController perf |
| Profiling | | Production perf-sensitive apps |
| Session Replay | | User-facing iOS/tvOS apps |
| Logging | | Structured log capture needed |
| User Feedback | | In-app bug reporting wanted |
For each feature: , follow steps exactly, verify it works.
Read ${SKILL_ROOT}/references/<feature>.md逐个配置已选定的功能。请阅读对应参考文档,严格按照步骤操作并验证后再进行下一个功能:
| 功能 | 参考文档 | 加载时机 |
|---|---|---|
| 错误监控 | | 必选(基础功能) |
| 追踪 | | 应用启动、网络请求、UIViewController性能监控时 |
| 性能分析 | | 生产环境性能敏感型应用 |
| 会话重放 | | 面向用户的iOS/tvOS应用 |
| 日志 | | 需要结构化日志捕获时 |
| 用户反馈 | | 需要应用内报错反馈时 |
每个功能的配置流程:,严格按照步骤操作,验证功能正常运行。
阅读${SKILL_ROOT}/references/<feature>.mdConfiguration Reference
配置参考
Key SentryOptions
Fields
SentryOptions关键SentryOptions
字段
SentryOptions| Option | Type | Default | Purpose |
|---|---|---|---|
| | | SDK disabled if empty; reads |
| | | e.g., |
| | | e.g., |
| | | Verbose SDK output — disable in production |
| | | Include IP, user info from active integrations |
| | | Master switch for crash reporting |
| | | Differentiates fully/non-fully blocked hangs |
| | | Seconds before classifying as hang |
| | | Track watchdog kills (iOS, tvOS, Mac Catalyst) |
| | | Capture screenshot on error |
| | | Capture view hierarchy on error |
| | | Transaction sample rate ( |
| | | Dynamic per-transaction sampling (overrides rate) |
| | | Master switch for auto-instrumentation |
| | | Hosts/regex that receive distributed trace headers |
| | | Auto-capture HTTP 5xx errors as events |
| | | Breadcrumbs for outgoing HTTP requests |
| | | Module prefixes treated as "in-app" code |
| | | Max breadcrumbs per event |
| | | Error event sample rate |
| | | Hook to mutate/drop error events |
| | | Called on next launch after a crash |
| 选项 | 类型 | 默认值 | 用途 |
|---|---|---|---|
| | | 为空时SDK禁用;优先读取 |
| | | 例如 |
| | | 例如 |
| | | 输出SDK详细日志 — 生产环境必须禁用 |
| | | 包含IP、活跃集成中的用户信息 |
| | | 崩溃报告总开关 |
| | | 区分完全阻塞和非完全阻塞的应用挂起 |
| | | 判定为挂起的超时时间(秒) |
| | | 追踪看门狗终止事件(iOS、tvOS、Mac Catalyst) |
| | | 错误发生时捕获截图 |
| | | 错误发生时捕获视图层级 |
| | | 事务采样率( |
| | | 动态事务采样逻辑(优先级高于固定采样率) |
| | | 自动检测性能总开关 |
| | | 接收分布式追踪头的主机/正则表达式 |
| | | 自动将HTTP 5xx错误捕获为事件 |
| | | 为 outgoing HTTP请求添加面包屑 |
| | | 被视为“应用内代码”的模块前缀 |
| | | 每个事件最多保留的面包屑数量 |
| | | 错误事件采样率 |
| | | 错误事件发送前的修改/丢弃钩子 |
| | | 应用崩溃后重启时触发 |
Environment Variables
环境变量
| Variable | Maps to | Purpose |
|---|---|---|
| | Data Source Name |
| | App version (e.g., |
| | Deployment environment |
| 变量 | 对应配置项 | 用途 |
|---|---|---|
| | 数据源名称 |
| | 应用版本(例如 |
| | 部署环境 |
Platform Feature Support Matrix
平台功能支持矩阵
| Feature | iOS | tvOS | macOS | watchOS | visionOS |
|---|---|---|---|---|---|
| Crash Reporting | ✅ | ✅ | ✅ | ✅ | ✅ |
| App Hangs V2 | ✅ | ✅ | ❌ | ❌ | ❌ |
| Watchdog Termination | ✅ | ✅ | ❌ | ❌ | ❌ |
| App Start Tracing | ✅ | ✅ | ❌ | ❌ | ✅ |
| UIViewController Tracing | ✅ | ✅ | ❌ | ❌ | ✅ |
| SwiftUI Tracing | ✅ | ✅ | ✅ | ❌ | ✅ |
| Network Tracking | ✅ | ✅ | ✅ | ❌ | ✅ |
| Profiling | ✅ | ✅ | ✅ | ❌ | ✅ |
| Session Replay | ✅ | ❌ | ❌ | ❌ | ❌ |
| MetricKit | ✅ (15+) | ❌ | ✅ (12+) | ❌ | ❌ |
| 功能 | iOS | tvOS | macOS | watchOS | visionOS |
|---|---|---|---|---|---|
| 崩溃报告 | ✅ | ✅ | ✅ | ✅ | ✅ |
| 应用挂起V2 | ✅ | ✅ | ❌ | ❌ | ❌ |
| 看门狗终止追踪 | ✅ | ✅ | ❌ | ❌ | ❌ |
| 应用启动追踪 | ✅ | ✅ | ❌ | ❌ | ✅ |
| UIViewController追踪 | ✅ | ✅ | ❌ | ❌ | ✅ |
| SwiftUI追踪 | ✅ | ✅ | ✅ | ❌ | ✅ |
| 网络追踪 | ✅ | ✅ | ✅ | ❌ | ✅ |
| 性能分析 | ✅ | ✅ | ✅ | ❌ | ✅ |
| 会话重放 | ✅ | ❌ | ❌ | ❌ | ❌ |
| MetricKit | ✅ (15+) | ❌ | ✅ (12+) | ❌ | ❌ |
Verification
验证
Test that Sentry is receiving events:
swift
// Trigger a test error event:
SentrySDK.capture(message: "Sentry Cocoa SDK test")
// Or test crash reporting (without debugger — crashes are intercepted by debugger):
// SentrySDK.crash() // uncomment, run without debugger, relaunch to see crash reportCheck the Sentry dashboard within a few seconds. If nothing appears:
- Set — prints SDK internals to Xcode console
options.debug = true - Verify the DSN is correct and the project exists
- Ensure initialization is on the main thread
测试Sentry是否能接收事件:
swift
// 触发测试错误事件:
SentrySDK.capture(message: "Sentry Cocoa SDK test")
// 或测试崩溃报告(需脱离调试器运行 — 调试器会拦截崩溃信号):
// SentrySDK.crash() // 取消注释,脱离调试器运行,重启应用后查看崩溃报告几秒内查看Sentry控制台。如果没有事件出现:
- 设置— 在Xcode控制台输出SDK内部日志
options.debug = true - 验证DSN格式正确且项目存在
- 确保SDK在主线程初始化
Production Settings
生产环境设置
Lower sample rates for production to control volume and cost:
swift
options.tracesSampleRate = 0.2 // 20% of transactions
options.configureProfiling = {
$0.sessionSampleRate = 0.1 // 10% of sessions
$0.lifecycle = .trace
}
options.sessionReplay.sessionSampleRate = 0.1 // 10% continuous
options.sessionReplay.onErrorSampleRate = 1.0 // 100% on error (keep high)
options.debug = false // never in production降低采样率以控制事件数量和成本:
swift
options.tracesSampleRate = 0.2 // 仅采样20%的事务
options.configureProfiling = {
$0.sessionSampleRate = 0.1 // 仅采样10%的会话
$0.lifecycle = .trace
}
options.sessionReplay.sessionSampleRate = 0.1 // 持续采样10%的会话
options.sessionReplay.onErrorSampleRate = 1.0 // 错误发生时100%采样(建议保持高比例)
options.debug = false // 生产环境绝对禁用Phase 4: Cross-Link
阶段4:跨链路配置
After completing Apple setup, check for a companion backend missing Sentry coverage:
bash
undefined完成Apple平台配置后,检查是否有未配置Sentry的配套后端服务:
bash
undefinedDetect companion backend
检测配套后端服务
ls ../backend ../server ../api 2>/dev/null
cat ../go.mod 2>/dev/null | head -5
cat ../requirements.txt ../Pipfile 2>/dev/null | head -5
cat ../Gemfile 2>/dev/null | head -5
cat ../package.json 2>/dev/null | grep -E '"name"|"dependencies"' | head -5
If a backend is found, configure `tracePropagationTargets` to enable distributed tracing end-to-end, and suggest the matching skill:
| Backend detected | Suggest skill | Trace header support |
|-----------------|--------------|---------------------|
| Go (`go.mod`) | `sentry-go-sdk` | ✅ automatic |
| Python (`requirements.txt`) | `sentry-python-sdk` | ✅ automatic |
| Ruby (`Gemfile`) | `sentry-ruby-sdk` | ✅ automatic |
| Node.js backend (`package.json`) | `sentry-node-sdk` (or `sentry-express-sdk`) | ✅ automatic |
---ls ../backend ../server ../api 2>/dev/null
cat ../go.mod 2>/dev/null | head -5
cat ../requirements.txt ../Pipfile 2>/dev/null | head -5
cat ../Gemfile 2>/dev/null | head -5
cat ../package.json 2>/dev/null | grep -E '"name"|"dependencies"' | head -5
如果检测到后端服务,配置`tracePropagationTargets`以实现端到端分布式追踪,并推荐对应的技能:
| 检测到的后端 | 推荐技能 | 追踪头支持 |
|-----------------|--------------|---------------------|
| Go (`go.mod`) | `sentry-go-sdk` | ✅ 自动支持 |
| Python (`requirements.txt`) | `sentry-python-sdk` | ✅ 自动支持 |
| Ruby (`Gemfile`) | `sentry-ruby-sdk` | ✅ 自动支持 |
| Node.js后端 (`package.json`) | `sentry-node-sdk`(或`sentry-express-sdk`) | ✅ 自动支持 |
---Troubleshooting
故障排除
| Issue | Solution |
|---|---|
| Events not appearing | Set |
| Crashes not captured | Run without debugger attached — debugger intercepts signals |
| App hangs not reported | Auto-disabled when debugger attached; check |
| Session Replay not recording | Check iOS version — disabled by default on iOS 26+ (Liquid Glass); verify |
| Tracing data missing | Confirm |
| Profiling data missing | Verify |
| Target Settings → "Enable User Script Sandbox" → |
| Multiple SPM products selected | Choose only one of |
| Removed in SDK 9.0.0 — use |
| Watchdog termination not tracked | Requires |
| Network breadcrumbs missing | Requires |
| Removed in SDK 9.0.0 — use |
| 问题 | 解决方案 |
|---|---|
| 事件未出现 | 设置 |
| 崩溃未被捕获 | 脱离调试器运行 — 调试器会拦截信号 |
| 应用挂起未上报 | 调试器运行时自动禁用;检查 |
| 会话重放未录制 | 检查iOS版本 — iOS 26+默认禁用(Liquid Glass限制);验证 |
| 追踪数据缺失 | 确认 |
| 性能分析数据缺失 | 验证 |
CocoaPods构建出现 | 目标设置 → "Enable User Script Sandbox" → 设置为 |
| 选择了多个SPM产品 | 仅选择 |
| SDK 9.0.0已移除该选项 — 仅使用 |
| 看门狗终止未被追踪 | 需确保 |
| 网络面包屑缺失 | 需确保 |
| SDK 9.0.0已移除该选项 — 使用 |