Skip to content

fix(ios): open the modal picker without AppDelegate.window - #978

Open
AlicanAkyol wants to merge 1 commit into
henninghall:masterfrom
AlicanAkyol:fix/uiscene-key-window
Open

AlicanAkyol wants to merge 1 commit into
henninghall:masterfrom
AlicanAkyol:fix/uiscene-key-window

Conversation

@AlicanAkyol

Copy link
Copy Markdown

openPicker gets the root view controller through [UIApplication sharedApplication].delegate.window.

With the UIKit scene life cycle the window belongs to the scene delegate and the AppDelegate has no window property. That is the React Native 0.88 template, and Expo SDK 58 (SDK 57 with enableSceneSupport). Apple requires the scene life cycle for apps built with the iOS 27 SDK (TN3187), and App Store uploads need that SDK from April 2027. In such an app, opening the modal picker throws:

-[AppDelegate window]: unrecognized selector sent to instance

This uses RCTKeyWindow().rootViewController from <React/RCTUtils.h> instead, so the picker is presented from the same controller as before. Behaviour is unchanged on the classic AppDelegate life cycle.

Testing: I reproduced this crash pattern, and confirmed the same fix, with two other libraries on a fresh React Native 0.88.0-rc.4 app in the iOS simulator (react-native-blob-util#498, invertase/react-native-google-mobile-ads#911, the latter now approved). I could not run it with this library on 0.88: 5.0.13 doesn't build there yet ('RCTComponent.h' file not found), which is a separate issue.

Found while adding a UIScene check to NativeKeel, a React Native health-check CLI I maintain.

openPicker read [UIApplication sharedApplication].delegate.window, which
apps on the UIKit scene life cycle (React Native 0.88 template, Expo SDK
58) do not have, so opening the modal picker threw '-[AppDelegate window]:
unrecognized selector'. Use RCTKeyWindow() from React's RCTUtils.h.

This branch has not been deployed

No deployments
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.

1 participant