
Sentry Cocoa Sdk
Wire Sentry’s Cocoa SDK into an iOS or macOS app so crashes, hangs, and failed HTTP calls show up in one dashboard while you ship solo.
Overview
Sentry Cocoa SDK is an agent skill for the Operate phase that documents how to configure sentry-cocoa for crashes, hangs, breadcrumbs, and HTTP error capture on Apple platforms.
Install
npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-cocoa-sdkWhat is this skill?
- Documents 15+ SDK configuration knobs (sampleRate, breadcrumbs, hang tracking, failed-request capture)
- Covers crash handlers, main-thread app hangs, and watchdog-termination heuristics
- HTTP client auto-capture with status-code ranges and host regex targets
- Optional screenshot attachment and stack-trace options (attachAllThreads on SDK 9.9+)
- Minimum version gates: sentry-cocoa v7.0+, Swift error improvements v8.7+, HTTP capture v8.0+
- Documents 15+ configuration options in a single table
- Default maxBreadcrumbs: 100 per event
- Default appHangTimeoutInterval: 2.0 seconds
Adoption & trust: 1.3k installs on skills.sh; 197 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You shipped an iOS or macOS app but crashes and API failures are invisible until users complain, with no clear map of which Sentry Cocoa options to enable.
Who is it for?
Indie mobile developers adding or tuning Sentry in Swift/Obj-C apps before or right after a TestFlight or App Store release.
Skip if: Teams only needing web or server Sentry SDKs, or builders who want a full incident-response playbook instead of Cocoa-specific configuration reference.
When should I use this skill?
User is integrating or tuning Sentry for a Cocoa/Swift/iOS/macOS project and needs SDK option names, defaults, and behavior.
What do I get? / Deliverables
You get a checklist-aligned SDK configuration (sampling, hangs, failed requests, attachments) so Sentry events reflect real production failures with less trial and error.
- Sentry Cocoa init and options block aligned to documented defaults
- Tuned sampling and failed-request capture rules for your API hosts
Recommended Skills
Journey fit
Error monitoring is a production concern: you tag and tune SDK behavior after the app exists and users can hit real failures. The skill centers on capturing and configuring error events (crashes, app hangs, HTTP client failures)—the canonical Operate → Errors shelf.
How it compares
SDK integration reference for Apple clients—not a generic Sentry MCP server or a cross-platform monitoring abstraction.
Common Questions / FAQ
Who is sentry-cocoa-sdk for?
Solo and small-team builders shipping iOS, macOS, or other Cocoa-based apps who want Sentry error and hang monitoring configured correctly from agent-assisted coding sessions.
When should I use sentry-cocoa-sdk?
Use it in Operate when diagnosing production crashes, during Ship when hardening release candidates with monitoring, or in Build when scaffolding Sentry init in a new Xcode project.
Is sentry-cocoa-sdk safe to install?
It is documentation-style guidance from the Sentry-for-AI skill pack; review the Security Audits panel on this Prism page and your org’s policy before letting an agent change production DSNs or sampling in CI.
SKILL.md
READMESKILL.md - Sentry Cocoa Sdk
# Error Monitoring — Sentry Cocoa SDK > Minimum SDK: `sentry-cocoa` v7.0.0+ > Swift Error improvements: v8.7.0+ > HTTP client error capture: v8.0.0+ ## Configuration | Option | Type | Default | Description | |--------|------|---------|-------------| | `enableCrashHandler` | `Bool` | `true` | Master switch for crash reporting (signal handlers, Mach exceptions, C++) | | `sampleRate` | `Float` (0.0–1.0) | `1.0` | Percentage of error events sent | | `attachStacktrace` | `Bool` | `true` | Attach stack traces to all captured messages | | `attachAllThreads` | `Bool` | `false` | Attach full stack traces for all threads (SDK 9.9+) | | `maxBreadcrumbs` | `Int` | `100` | Max breadcrumbs per event | | `enableAppHangTracking` | `Bool` | `true` | Detect main thread unresponsiveness | | `appHangTimeoutInterval` | `Double` | `2.0` | Seconds before a hang is reported | | `enableReportNonFullyBlockingAppHangs` | `Bool` | `true` | Include non-fully-blocking hangs where V2 is supported | | `enableWatchdogTerminationTracking` | `Bool` | `true` | Track OS watchdog kills via heuristics | | `enableCaptureFailedRequests` | `Bool` | `true` | Auto-capture HTTP client errors as Sentry events | | `failedRequestStatusCodes` | `[HttpStatusCodeRange]` | `[500–599]` | Status code ranges that trigger error capture | | `failedRequestTargets` | `[String]` | `[".*"]` | Hosts/regex patterns to monitor for HTTP errors | | `attachScreenshot` | `Bool` | `false` | Capture screenshot when an error event fires | | `attachViewHierarchy` | `Bool` | `false` | Capture view hierarchy when an error event fires | | `sendDefaultPii` | `Bool` | `false` | Include PII (IP address, username) in events | ## Code Examples ### SDK initialization ```swift import Sentry SentrySDK.start { options in options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0" options.environment = "production" options.releaseName = "my-app@2.0.0+123" options.enableCrashHandler = true // default; explicit for clarity options.attachScreenshot = true options.attachViewHierarchy = true } ``` ### Capture a message ```swift SentrySDK.capture(message: "Something noteworthy happened") ``` ### Capture a Swift Error / NSError ```swift do { try riskyOperation() } catch { SentrySDK.capture(error: error) } ``` ### Capture a custom SentryEvent ```swift let event = Event(level: .warning) event.message = SentryMessage(formatted: "Checkout flow aborted") event.tags = ["feature": "checkout"] event.extra = ["cart_items": 3] SentrySDK.capture(event: event) ``` ### Swift Error enum — human-readable titles (v8.7.0+) By default, Swift error enum cases appear as `LoginError - Code: 1`. To get readable titles, conform to `CustomNSError`: ```swift enum LoginError: Error { case wrongUser(id: String) case wrongPassword } extension LoginError: CustomNSError { var errorUserInfo: [String: Any] { [NSDebugDescriptionErrorKey: debugDescription] } private var debugDescription: String { switch self { case .wrongUser(let id): return "Wrong user (id: \(id))" case .wrongPassword: return "Wrong password" } } } // Captures "LoginError - Wrong user (id: 12345)" as the issue title SentrySDK.capture(error: LoginError.wrongUser(id: "12345")) ``` > Use `NSDebugDescriptionErrorKey`, NOT `NSLocalizedDescriptionKey`. Localized strings vary by device locale and create duplicate issues. ### Capture with per-event scope The scope callback receives an isolated copy — changes don't affect global state: ```swift SentrySDK.capture(error: error) { scope in scope.setTag(value: "checkout", key: "feature") scope.setContext(value: ["amount": 99.99, "currency": "USD"], key: "payment") } SentrySDK.capture(message: "Payment declined") { scope in scope.setLevel(.fatal) scope.setTag(value: "stripe", key: "payment_provider") } ``` ### App hang detection ```swift SentrySDK.start { options in options.dsn = "___PUBLIC_DSN___"