watchOS
Features:
- Limited symbolication support and no crash handling
- Events enriched with device data
- Offline caching when a device is unable to connect; we send a report once we receive another event
- Attachments enrich your event by storing additional files, such as config or log files
- User Feedback provides the ability to collect user information when an event occurs
On this page, we get you up and running with Sentry's SDK, so that it will automatically report errors and exceptions in your application.
Don't already have an account and Sentry project established? Head over to sentry.io, then return to this page.
Install
Sentry captures data by using an SDK within your application’s runtime.
The minimum version for watchOS is 2.0. Our SDK has limited symbolication support and no crash or app hang detection for watchOS.
We recommend installing the SDK with CocoaPods, but we also support alternate installation methods. To integrate Sentry into your Xcode project, specify it in your Podfile
:
platform :watchos, '2.0'
use_frameworks! # This is important
target 'YourApp' do
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '8.7.3'
end
Then run pod install
.
Configure
Configuration should happen as early as possible in your application's lifecycle.
You should also initialize the SDK as soon as possible, such as in your AppDelegate application:didFinishLaunchingWithOptions
method:
import Sentry // Make sure you import Sentry
// ....
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
SentrySDK.start { options in
options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
options.debug = true // Enabled debug when first installing is always helpful
}
return true
}
When using SwiftUI and your app doesn't implement an app delegate, initialize the SDK within the App conformer's initializer:
import Sentry
@main
struct SwiftUIApp: App {
init() {
SentrySDK.start { options in
options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
options.debug = true // Enabled debug when first installing is always helpful
}
}
}
Experimental features
Want to play with some new features? Try out our experimental features for file I/O, Core Data, User Interaction Instrumentation, Screenshots. Experimental features are still a work-in-progress and may have bugs. We recognize the irony.
Let us know if you have feedback through GitHub issues.
import Sentry
SentrySDK.start { options in
// ...
// Enable all experimental features
options.enablePreWarmedAppStartTracing = true
options.attachScreenshot = true
options.attachViewHierarchy = true
options.enableMetricKit = true
options.swiftAsyncStacktraces = true
}
Stitch Together Swift Concurrency Stack Traces
If you use Swift concurrency, this feature will stitch your stack traces together. That means you will be able to see the full stack trace of your async code.
For this to happen you need to enable the swiftAsyncStacktraces
option.
You can also enable this in your Objective-C project, however, only async code written in Swift will be stitched together.
import Sentry
SentrySDK.start { options in
// ...
options.swiftAsyncStacktraces = true
}
Use Sentry with SwiftUI
If you want to find out the performance of your Views in a SwiftUI project, try the SentrySwiftUI library.
Provide Debug Information
To capture crashes, you need to provide debug information to Sentry. You can also use our source context feature to display code snippets next to the event stack traces by enabling the include-sources
option when uploading your debug information files. Debug information is provided by uploading dSYM files.
Verify
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
import Sentry
do {
try aMethodThatMightFail()
} catch {
SentrySDK.capture(error: error)
}
Learn more about manually capturing an error or message in our Usage documentation.
To view and resolve the recorded error, log into sentry.io and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
- Package:
- cocoapods:sentry-cocoa
- Version:
- 8.7.3
- Repository:
- https://github.com/getsentry/sentry-cocoa