Token导航 LogoToken导航TokenDH.com
开发敏感数据github未标认证来源可访问许可证需确认审计通过

sentry-cocoa-sdkSentry cocoa SDK 命令行

Agent Skill

sentry-cocoa-sdk 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

17,088

周安装

734

GitHub Stars

156

下载量

5,989
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:sentry-cocoa-sdk(Sentry cocoa SDK 命令行)
来源仓库:https://github.com/getsentry/sentry-for-ai
仓库路径:skills/sentry-cocoa-sdk
安装命令:
npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-cocoa-sdk
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-cocoa-sdk

简介

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在需要围绕仓库状态、代码变更或协作事项进行整理时使用。
  • 可结合来源仓库和原始 README 继续核验具体用法。
  • 安装前建议确认权限范围和维护状态,避免触发不必要的联网或命令执行。
  • 注意区分只读查询与写入操作,确保操作边界清晰。

SKILL.md

All Skills > SDK Setup > Cocoa SDK

Sentry Cocoa SDK

Opinionated wizard that scans your Apple project and guides you through complete Sentry setup.

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, SentrySDK, or the Apple/iOS Sentry SDK
  • 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.

Phase 1: Detect

Run these commands to understand the project before making any recommendations:

# Check existing Sentry dependency
grep -i sentry Package.swift Podfile Cartfile 2>/dev/null

# Detect UI framework (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

# 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

# Detect logging
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.)

Phase 2: Recommend

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:

FeatureRecommend when...
Error MonitoringAlways — non-negotiable baseline
TracingAlways for apps — rich auto-instrumentation out of the box
ProfilingProduction apps where performance matters
Session ReplayiOS only user-facing apps (check iOS 26+ caveat; not tvOS/macOS/watchOS/visionOS)
LoggingExisting os.log / CocoaLumberjack usage, or structured logs needed
User FeedbackApps wanting in-app bug reports with screenshots

Propose: *"I recommend Error Monitoring + Tracing + Profiling. Want me to also add Session Replay and Logging?"*


Phase 3: Guide

Install

Option 1 — Sentry Wizard (recommended):

You need to run this yourself — the wizard opens a browser for login and requires interactive input that the agent can't handle. Copy-paste into your terminal: `` brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios `` It handles login, org/project selection, auth token setup, SDK installation, AppDelegate updates, and dSYM/debug symbol upload build phases. Once it finishes, come back and skip to Verification.

If the user skips the wizard, proceed with Option 2 (SPM/CocoaPods) and manual setup below.

Option 2 — Swift Package Manager: File → Add Packages → enter:

https://github.com/getsentry/sentry-cocoa.git

Or in Package.swift:

.package(url: "https://github.com/getsentry/sentry-cocoa", from: "9.5.1"),

SPM Products — choose exactly one per target:

ProductUse Case
SentryRecommended — static framework, fast app start
Sentry-DynamicDynamic framework alternative
SentrySwiftUISwiftUI view performance tracking (SentryTracedView)
Sentry-WithoutUIKitOrAppKitwatchOS, app extensions, CLI tools (Swift < 6.1)
SentrySPM + NoUIFramework traitwatchOS, app extensions, macOS CLI tools (Swift 6.1+ / Xcode 16.3+ only)
⚠️ Xcode allows selecting multiple products — choose only one.

Swift 6.1+ trait-based opt-out of UIKit/AppKit (requires Package@swift-6.1.swift manifest):

// Package.swift (Swift 6.1+)
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "9.5.1"),

// In your target's dependencies:
.product(name: "SentrySPM", package: "sentry-cocoa", condition: .when(traits: ["NoUIFramework"]))

This is the preferred opt-out path for macOS command-line tools and app extensions on Swift 6.1+. For Swift < 6.1 continue using Sentry-WithoutUIKitOrAppKit.

Note: Package traits are visible in the Xcode UI starting with Xcode 26.4+ (currently in beta). On older Xcode versions, traits still work when declared in Package.swift but won't appear in the GUI.

Option 3 — CocoaPods:

platform :ios, '11.0'
use_frameworks!

target 'YourApp' do
  pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '9.5.1'
end
Known issue (Xcode 14+): Sandbox rsync.samba error → Target Settings → "Enable User Script Sandbox" → 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:

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:

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.

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:

FeatureReference fileLoad when...
Error Monitoring${SKILL_ROOT}/references/error-monitoring.mdAlways (baseline)
Tracing${SKILL_ROOT}/references/tracing.mdApp launch, network, UIViewController perf
Profiling${SKILL_ROOT}/references/profiling.mdProduction perf-sensitive apps
Session Replay${SKILL_ROOT}/references/session-replay.mdUser-facing iOS/tvOS apps
Logging${SKILL_ROOT}/references/logging.mdStructured log capture needed
User Feedback${SKILL_ROOT}/references/user-feedback.mdIn-app bug reporting wanted

For each feature: Read ${SKILL_ROOT}/references/<feature>.md, follow steps exactly, verify it works.


Configuration Reference

Key SentryOptions Fields

OptionTypeDefaultPurpose
dsnString""SDK disabled if empty; reads SENTRY_DSN env var
environmentString""e.g., "production"; reads SENTRY_ENVIRONMENT
releaseNameString""e.g., "my-app@1.0.0"; reads SENTRY_RELEASE
debugBoolfalseVerbose SDK output — disable in production
sendDefaultPiiBoolfalseInclude IP, user info from active integrations
enableCrashHandlerBooltrueMaster switch for crash reporting
enableAppHangTrackingV2Booltrue (9.0+)Differentiates fully/non-fully blocked hangs
appHangTimeoutIntervalDouble2.0Seconds before classifying as hang
enableWatchdogTerminationTrackingBooltrueTrack watchdog kills (iOS, tvOS, Mac Catalyst)
attachScreenshotBoolfalseCapture screenshot on error
attachViewHierarchyBoolfalseCapture view hierarchy on error
tracesSampleRateNSNumber?nilTransaction sample rate (nil = tracing disabled); Swift auto-boxes Double literals (e.g. 1.0NSNumber)
tracesSamplerClosurenilDynamic per-transaction sampling (overrides rate)
enableAutoPerformanceTracingBooltrueMaster switch for auto-instrumentation
tracePropagationTargets[String][".*"]Hosts/regex that receive distributed trace headers
enableCaptureFailedRequestsBooltrueAuto-capture HTTP 5xx errors as events
enableNetworkBreadcrumbsBooltrueBreadcrumbs for outgoing HTTP requests
inAppInclude[String][]Module prefixes treated as "in-app" code
maxBreadcrumbsInt100Max breadcrumbs per event
sampleRateFloat1.0Error event sample rate
beforeSendClosurenilHook to mutate/drop error events
onCrashedLastRunClosurenilCalled on next launch after a crash
strictTraceContinuationBoolfalseReject incoming traces from other orgs; validates org_id in baggage headers (sentry-cocoa ≥9.10.0)
orgIdString?nilOrganization ID for strict trace validation; auto-parsed from DSN host (e.g. o123.ingest.sentry.io"123") if not set explicitly

Environment Variables

VariableMaps toPurpose
SENTRY_DSNdsnData Source Name
SENTRY_RELEASEreleaseNameApp version (e.g., my-app@1.0.0)
SENTRY_ENVIRONMENTenvironmentDeployment environment

Platform Feature Support Matrix

FeatureiOStvOSmacOSwatchOSvisionOS
Crash Reporting
App Hangs V2
Watchdog Termination
App Start Tracing
UIViewController Tracing
SwiftUI Tracing
Network Tracking
Profiling
Session Replay
MetricKit✅ (15+)✅ (12+)

Verification

Test that Sentry is receiving events:

// 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 report

Check the Sentry dashboard within a few seconds. If nothing appears:

  1. Set options.debug = true — prints SDK internals to Xcode console
  2. Verify the DSN is correct and the project exists
  3. Ensure initialization is on the main thread

Production Settings

Lower sample rates for production to control volume and cost:

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

Phase 4: Cross-Link

After completing Apple setup, check for a companion backend missing Sentry coverage:

# Detect 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 detectedSuggest skillTrace 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

Troubleshooting

IssueSolution
Events not appearingSet debug: true, verify DSN format, ensure init is on main thread
Crashes not capturedRun without debugger attached — debugger intercepts signals
App hangs not reportedAuto-disabled when debugger attached; check appHangTimeoutInterval
Session Replay not recordingCheck iOS version — disabled by default on iOS 26+ (Liquid Glass); verify sessionSampleRate > 0
Tracing data missingConfirm tracesSampleRate > 0; check enableAutoPerformanceTracing = true
Profiling data missingVerify sessionSampleRate > 0 in configureProfiling; for .trace lifecycle, tracing must be enabled
rsync.samba build error (CocoaPods)Target Settings → "Enable User Script Sandbox" → NO
Multiple SPM products selectedChoose only one of Sentry, Sentry-Dynamic, SentrySwiftUI, Sentry-WithoutUIKitOrAppKit, or SentrySPM (with NoUIFramework trait on Swift 6.1+)
inAppExclude compile errorRemoved in SDK 9.0.0 — use inAppInclude only
Watchdog termination not trackedRequires enableCrashHandler = true (it is by default)
Network breadcrumbs missingRequires enableSwizzling = true (it is by default)
profilesSampleRate compile errorRemoved in SDK 9.0.0 — use configureProfiling closure instead

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.54%
按下载量换算2,188

Claude

29.92%
按下载量换算1,792

Cursor

20.08%
按下载量换算1,203

Gemini CLI

9.5%
按下载量换算569

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills