getsentry/agent-skills
Overview
This skill sets up Sentry in iOS apps written in Swift or SwiftUI, installing and configuring the sentry-cocoa SDK for error monitoring, performance tracing, session replay, and log collection. It provides recommended install methods, sample initialization for SwiftUI and UIKit, and guidance for production tuning and verification. It is focused on iOS 13+, Xcode 15+, and Swift 5+.
How this skill works
The skill guides you to add Sentry via Swift Package Manager or CocoaPods, then initialize SentrySDK in your App lifecycle (SwiftUI @main or UIKit AppDelegate). It shows configuration options for DSN, tracesSampleRate, session replay, profiling, logs, and attachments, and includes examples for user context, masking session replay, and sending test events. It also covers size analysis upload using Fastlane and common troubleshooting steps.
When to use it
- Adding Sentry to a new or existing iOS Swift or SwiftUI app
- Enabling crash reporting, performance tracing, or session replay
- Configuring Sentry options for production vs development
- Verifying Sentry integration with test events and crash calls
- Uploading size analysis from CI using Fastlane
Best practices
- Use Swift Package Manager for easier version management and updates
- Keep options.debug = false in production and tune tracesSampleRate to limit telemetry volume
- Set sessionReplay.sessionSampleRate and onErrorSampleRate according to privacy and cost constraints
- Attach minimal contextual data: enable screenshot/view hierarchy only when necessary and compliant
- Store SENTRY_AUTH_TOKEN in CI environment variables for Fastlane uploads and add .sentryclirc to .gitignore if used
Example use cases
- Install sentry-cocoa via SPM and initialize in SwiftUI @main with DSN and tracing enabled
- Add Sentry to a UIKit app by calling SentrySDK.start in AppDelegate didFinishLaunchingWithOptions
- Mask sensitive fields in session replay using sentryReplayMask and unmask safe UI elements
- Send a test message with SentrySDK.capture(message:) to validate events reach Sentry
- Configure Fastlane lane to upload size analysis to Sentry from CI
FAQ
iOS 13.0+, Xcode 15.0+, and Swift 5.0+ are required for the current SDK usage described.
How do I test that Sentry is working?
Use SentrySDK.capture(message: "Test from iOS") to send a test event and SentrySDK.crash() for a development-only crash test; enable debug=true during verification to see SDK logs.