Skip to content

Commit

Permalink
feat(apple): Add docs for swizzleClassNameExcludes (#10992)
Browse files Browse the repository at this point in the history
Add docs for the existing option swizzleClassNameExcludes.

Co-authored-by: Karl Heinz Struggl <[email protected]>
  • Loading branch information
philipphofmann and kahest committed Aug 14, 2024
1 parent 954471f commit 469b818
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/platforms/apple/common/configuration/swizzling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,34 @@ SentrySDK.start { options in
options.enableSwizzling = NO;
}];
```
## Deactivate Swizzling for Specific Classes
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`
```swift {tabTitle:Swift}
import Sentry
SentrySDK.start { options in
options.swizzleClassNameExcludes = [
"MyUIViewController",
]
}
```

```objc {tabTitle:Objective-C}
@import Sentry;

[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.swizzleClassNameExcludes = [NSSet setWithObjects:
@"MyUIViewController",
nil
];
}];
```
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,33 @@ SentrySDK.start { options in
}];
```
You can deactivate tracing for specific UIViewControllers by configuring <PlatformLink to="/configuration/swizzling#skip-swizzling-for-specific-classes">`swizzleClassNameExcludes`</PlatformLink>:
```swift {tabTitle:Swift}
import Sentry
SentrySDK.start { options in
options.swizzleClassNameExcludes = [
"MyUIViewController",
]
}
```

```objc {tabTitle:Objective-C}
@import Sentry;

[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.swizzleClassNameExcludes = [NSSet setWithObjects:
@"MyUIViewController",
nil
];
}];
```
[UIViewController]: https://developer.apple.com/documentation/uikit/uiviewcontroller
## App Start Tracing
This feature is available for iOS, tvOS, and Mac Catalyst.
Expand Down

0 comments on commit 469b818

Please sign in to comment.