Skip to content

Commit 33c9619

Browse files
philprimeitaybre
andauthored
fix: Resolve SDK crash caused by UIPrintPanelViewController incorrectly casting to UISplitViewController (#6771)
* fix: Resolve SDK crash caused by UIPrintPanelViewController incorrectly casting to UISplitViewController * update changelog * Update changelog --------- Co-authored-by: Itay Brenner <[email protected]>
1 parent 40ef20e commit 33c9619

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- Remove unnecesary dependency on `SentryCppHelper` to Sentry (#6754) (#6761)
8+
- Resolve SDK crash caused by UIPrintPanelViewController incorrectly casting to UISplitViewController (#6771)
89

910
## 8.57.2
1011

Sources/Swift/Helper/SentryApplicationExtensions.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,18 @@ extension SentryApplication {
136136
return nil
137137
}
138138
}
139+
139140
if let splitViewController = vc as? UISplitViewController {
140-
if splitViewController.viewControllers.count > 0 {
141+
// We encountered a case where the private class `UIPrintPanelViewController` overrides the `isKindOfClass:` method and wrongfully
142+
// allows casting to `UISplitViewController`, while not actually being a subclass:
143+
//
144+
// -[UIPrintPanelViewController viewControllers]: unrecognized selector sent to instance 0x124f45e00
145+
//
146+
// Check if the selector exists as a double-check mechanism
147+
// See: https://github.com/getsentry/sentry-cocoa/issues/6725
148+
if !splitViewController.responds(to: NSSelectorFromString("viewControllers")) {
149+
SentrySDKLog.warning("Failed to get viewControllers from UISplitViewController. This is a known bug in iOS 26.1")
150+
} else if splitViewController.viewControllers.count > 0 {
141151
return splitViewController.viewControllers
142152
}
143153
}

0 commit comments

Comments
 (0)