Swizzling
Learn which features use swizzling
The Cocoa SDK uses swizzling to provide some features out of the box without boilerplate code. The following features use swizzling:
macOS
- Breadcrumbs for touch events
- Auto instrumentation for HTTP requests
- Auto instrumentation for File I/O operations
- Auto instrumentation for Core Data operations
- Automatically added sentry-trace header to HTTP requests for distributed tracing
- HTTP Client Errors
iOS, tvOS and Catalyst
- Breadcrumbs for touch events and navigation with UIViewControllers
- Auto instrumentation for UIViewControllers
- Auto instrumentation for HTTP requests
- Auto instrumentation for File I/O operations
- Auto instrumentation for Core Data operations
- Automatically added sentry-trace header to HTTP requests for distributed tracing
- User interaction transactions for UI clicks
- HTTP Client Errors
Since Cocoa 7.5.0, you can opt out of swizzling using options. When you disable swizzling, the SDK disables the features above:
Copied
import Sentry
SentrySDK.start { options in
options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
options.enableSwizzling = false
}
To deactivate swizzling for specific classes, you can use the option swizzleClassNameExcludes
, which is available with Sentry Cocoa SDK version 8.23.0
and above. The SDK checks if the name of a class it intends to swizzle contains any class name configured using this option. For example, if you add MyUIViewController
to this list, the Sentry Cocoa SDK excludes the following classes from swizzling:
YourApp.MyUIViewController
YourApp.MyUIViewControllerA
MyApp.MyUIViewController
Copied
import Sentry
SentrySDK.start { options in
options.swizzleClassNameExcludes = [
"MyUIViewController",
]
}
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").