From 469a11fca17c9a7fbe7962c7fe9f1c01d4f6e4a2 Mon Sep 17 00:00:00 2001 From: Tim Oliver Date: Thu, 20 Nov 2025 16:36:33 +0900 Subject: [PATCH] Add manual selector check for creating UIGlassEffect --- .../TOCropViewController/Views/TOCropToolbar.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Objective-C/TOCropViewController/Views/TOCropToolbar.m b/Objective-C/TOCropViewController/Views/TOCropToolbar.m index cdd5eb69..38ca2180 100644 --- a/Objective-C/TOCropViewController/Views/TOCropToolbar.m +++ b/Objective-C/TOCropViewController/Views/TOCropToolbar.m @@ -61,7 +61,19 @@ - (void)setup { if (@available(iOS 26.0, *)) { UIVisualEffect *effect = nil; #if !TARGET_OS_VISION - UIGlassEffect *glassEffect = [UIGlassEffect effectWithStyle:UIGlassEffectStyleClear]; + // We've been getting reports that some devices have been crashing with the error message + // that `effectWithStyle` was unrecognized. The ONLY way this seems to be possible + // is if there are users out there using the beta versions of iOS 26.0 before this method + // was introduced. Either way, we're going to need to manually confirm the selector exists + // in order to fix these crashes. + + UIGlassEffect *glassEffect = nil; + SEL effectSelector = NSSelectorFromString(@"effectWithStyle:"); + if ([[UIGlassEffect class] respondsToSelector:effectSelector]) { + glassEffect = [UIGlassEffect effectWithStyle:UIGlassEffectStyleClear]; + } else { + glassEffect = [UIGlassEffect new]; + } glassEffect.interactive = YES; effect = glassEffect; #else