Setup Sentry in iOS/Swift apps. Use when asked to add Sentry to iOS, install sentry-cocoa SDK, or configure error monitoring, tracing, session replay, logging, or profiling for iOS applications using Swift and SwiftUI.
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
Setup Sentry in iOS/Swift apps. Use when asked to add Sentry to iOS, install sentry-cocoa SDK, or configure error monitoring, tracing, session replay, logging, or profiling for iOS applications using Swift and SwiftUI.
Setup Sentry for iOS (Swift)
This skill helps configure Sentry's iOS SDK (sentry-cocoa) for Swift and SwiftUI applications, including error monitoring, tracing, session replay, structured logging, and profiling.
When to Use This Skill
Invoke this skill when:
User asks to "setup Sentry for iOS" or "add Sentry to my Swift app"
User wants error monitoring, crash reporting, or performance monitoring for iOS
User requests session replay, tracing, logging, or profiling for iOS
User mentions "sentry-cocoa" or SentrySDK.start
Platform Detection
Before configuring, verify this is an iOS/Swift project:
// WARNING: Only for development/testing
options.sessionReplay.maskAllText =false
options.sessionReplay.maskAllImages =false
Custom Spans
With tracing enabled, Sentry automatically instruments app launches, URLSession requests, UI transitions, File I/O, Core Data, and app hangs.
For custom operations:
// Simple spanlet span =SentrySDK.span
let childSpan = span?.startChild(operation: "custom.operation", description: "Processing data")
// Do work...
childSpan?.finish()
// Async/await patternfuncprocessOrder(_orderId: String) asyncthrows -> Order {
let span =SentrySDK.span?.startChild(
operation: "order.process",
description: "Processing order \(orderId)"
)
defer { span?.finish() }
span?.setData(value: orderId, key: "order.id")
let order =tryawait orderService.process(orderId)
span?.setData(value: order.total, key: "order.total")
return order
}
User Context
// Set user after authenticationlet user =User()
user.userId ="user_123"
user.email ="user@example.com"
user.username ="johndoe"SentrySDK.setUser(user)
// Clear on logoutSentrySDK.setUser(nil)
Manual Error Capture
// Capture an errordo {
try riskyOperation()
} catch {
SentrySDK.capture(error: error)
}
// Capture with extra contextSentrySDK.capture(error: error) { scope in
scope.setTag(value: "checkout", key: "feature")
scope.setExtra(value: orderId, key: "order_id")
}
Verification Steps
// Test error captureSentrySDK.capture(message: "Test message from iOS app")
// Test loggingSentrySDK.logger.info("Test log from iOS app", attributes: ["test": true])
Check in Sentry:
Issues - Look for test message
Performance - Look for app start transactions
Replays - Look for session recordings
Logs - Look for test log entry
Common Issues and Solutions
Issue: Events not appearing in Sentry
Solutions:
Verify DSN is correct
Check options.debug = true for console output
Ensure network connectivity
Wait 1-2 minutes for events to process
Issue: Session Replay not recording
Solutions:
Verify sessionSampleRate > 0
Check SDK version is 8.0.0+
For SwiftUI, check masking isn't hiding everything
Issue: Tracing spans missing
Solutions:
Verify tracesSampleRate > 0
Ensure spans are properly finished with .finish()
Issue: Logs not appearing
Solutions:
Verify options.enableLogs = true
Check SDK version is 8.55.0+
Verify beforeSendLog isn't filtering everything
Issue: CocoaPods installation fails
Solutions:
Run pod repo update
Delete Podfile.lock and Pods/ directory, re-run pod install
Ensure minimum iOS deployment target is 13.0+
Summary Checklist
## Sentry iOS Setup Complete### Installation:- [ ] SDK added via Swift Package Manager or CocoaPods
- [ ] SDK version 9.0.0+ installed
### Configuration Applied:- [ ] DSN configured
- [ ] Environment set
- [ ] attachScreenshot / attachViewHierarchy enabled
- [ ] Tracing (tracesSampleRate)
- [ ] Profiling (configureProfiling)
- [ ] Session Replay (sessionReplay settings)
- [ ] Logging (enableLogs)
### Next Steps:1. Set appropriate sample rates for production
2. Configure user context after authentication
3. Review masking for sensitive screens
4. Add custom spans for important operations