Skip to content

fix(ios): presenting view controller crashes with the UIScene life cycle (React Native 0.88 template) - #498

Merged
RonRadtke merged 1 commit into
RonRadtke:masterfrom
AlicanAkyol:fix/uiscene-presenting-view-controller
Nov 9, 2026
Merged

RonRadtke merged 1 commit into
RonRadtke:masterfrom
AlicanAkyol:fix/uiscene-presenting-view-controller

Conversation

@AlicanAkyol

Copy link
Copy Markdown

What breaks

React Native 0.88's app template moves the window to a SceneDelegate. Apps need the UIScene life cycle to launch once they are built with the iOS 27 SDK, which App Store Connect requires from April 2027. The template's AppDelegate no longer has a window property:

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
  func application(_ application: UIApplication, didFinishLaunchingWithOptions ...) -> Bool { true }
}

The module's presenting-view-controller provider sends window to the app delegate, so the first call that presents UI ends the app:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'ReactNativeBlobUtil.presentOptionsMenu raised an exception: -[SceneTest.AppDelegate window]:
unrecognized selector sent to instance 0x600000014900'

The fix

RCTPresentedViewController() from React/RCTUtils.h resolves the key window through connectedScenes and walks up to the top-most presented controller. It works with or without scenes, and it has been in React Native since long before 0.68, so nothing changes for older apps.

How I tested it

I used a fresh @react-native-community/cli init app on React Native 0.88.0-rc.4, with its template unchanged (SceneDelegate, no window on AppDelegate). The app writes a file and calls ReactNativeBlobUtil.ios.presentOptionsMenu(path) 3 s after launch. Each run was a release build on an iOS 26.2 simulator (iPhone Air):

Build Result
react-native-blob-util 0.25.1 from npm crashes with the exception above
0.25.1 with the same line changed to RCTPresentedViewController() options menu shows, app keeps running
this branch (1.1.0 + fix), packed with npm pack options menu shows, app keeps running

The android/gradlew.bat line-ending change that a fresh checkout shows is not part of this PR.

(Found while scanning the iOS sources of popular React Native libraries for the UIScene move with NativeKeel. This pattern shows up in about a dozen packages.)

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.
@RonRadtke
RonRadtke merged commit 44f53fa into RonRadtke:master Nov 9, 2026
RonRadtke added a commit that referenced this pull request Nov 9, 2026
The pull requests merged since 1.1.0 (#498, #499, #501, #503, #505, #507)
and the fixes from a pass over the open issues (#197, #334, #377, #384,
#390, #411/#256, #425, #486). Migration.md lists each change under 1.1.1.
RonRadtke added a commit that referenced this pull request Nov 9, 2026
…port of #498)

presentOptionsMenu and presentOpenInMenu took the view to present from as
[[[[UIApplication sharedApplication] delegate] window] rootViewController].
React Native 0.88's template moves the window to a scene delegate, and apps
need the UIScene life cycle to launch once they build with the iOS 27 SDK,
so the template's AppDelegate has no `window` and the first menu ended the
app: "-[AppDelegate window]: unrecognized selector sent to instance". The
preview delegate method used the deprecated keyWindow's root controller.

All three now use RCTPresentedViewController(), which finds the key window
through the connected scenes and walks up to the controller on top, as #498
does on master. That also makes a menu opened over a modal screen appear:
UIKit does not present from a controller that is already presenting one, so
it did nothing (#311). The two menu lookups moved inside the main-queue
blocks that already present them, because the helper reads UIKit state; the
old lookup ran on the module's queue.

0.25 has no iOS unit test target. The same provider is covered by XCTests
on master; #498's author verified this change on 0.25.1 in a React Native
0.88 app (the options menu shows, the app keeps running). Not compiled on
this machine.
RonRadtke added a commit that referenced this pull request Nov 9, 2026
Migration.md is the guide from 0.25 to 1.x. A crash or a call that did
nothing, fixed in 1.1.1, is nothing to migrate around, so its row only
repeated the release notes: the iOS document menus (#498), an empty
multipart form on iOS (#197), the Downloads-app entry on Android (#390),
open.chooser on Android (#486) and lstat on an unreadable folder (#425).
They are gone; the row for that folder keeps the one visible change, ls
rejecting EACCES instead of EUNSPECIFIED. The release notes list every fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants