From 546f4ffe749330b312ef91bbccff4a753d6aee12 Mon Sep 17 00:00:00 2001 From: Alican Akyol <11759370+AlicanAkyol@users.noreply.github.com> Date: Sat, 10 Oct 2026 09:47:02 +0300 Subject: [PATCH] fix(ios): find the presenting view controller through the window scene The presenting-view-controller provider sent `window` to the app delegate. React Native 0.88's template moves the window to SceneDelegate (the UIScene life cycle is required to launch once an app is built with the iOS 27 SDK), and its AppDelegate has no `window`, so presenting the options or open-in menu threw: -[AppDelegate window]: unrecognized selector sent to instance RCTPresentedViewController() resolves the key window through the connected scenes and returns the top-most presented controller. It has been in React/RCTUtils.h since well before 0.68, so older apps keep working. --- ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm b/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm index e21acae1..26e20f4e 100644 --- a/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm +++ b/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm @@ -12,6 +12,7 @@ // #import "ReactNativeBlobUtil.h" +#import // The seam, not the Swift module. Under SwiftPM this file compiles in its own // target and cannot see the Swift core's generated -Swift.h, so it names a @@ -55,8 +56,12 @@ - (id) init { [_core setWarningHandler:^(NSString *message) { RCTLogWarn(@"%@", message); }]; + // RCTPresentedViewController() finds the key window through the connected scenes, so it + // works with the UIScene life cycle (React Native 0.88's template, required to launch when + // built with the iOS 27 SDK). That template's AppDelegate has no `window`, and sending it + // one threw "-[AppDelegate window]: unrecognized selector". _core.presentingViewController = ^UIViewController * _Nullable { - return [[[[UIApplication sharedApplication] delegate] window] rootViewController]; + return RCTPresentedViewController(); }; if (commonTaskQueue == nil) commonTaskQueue = dispatch_queue_create("ReactNativeBlobUtil.queue", DISPATCH_QUEUE_SERIAL);