Application Scene Delegates support in RN >= 0.74
まだ誰も着手していません。
- 主要言語
- C++
- スター
- 127k
- フォーク
- 25.3k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 4
説明
Description
When we added CarPlay support to our React Native app we needed to switch from App Delegate to Application Scene Delegates.
Independently of whether the app was started on the phone (PhoneScene) or on the CarPlay-client (CarScene), the first code to run natively will always be the AppDelegates application:didFinishLaunchingWithOptions: method.
A React Native app usually calls the super-method in its AppDelegate, which is implemented in React Native's own RCTAppDelegate. The problem with this is that RCTAppDelegate assumes a phone usage and creates a rootViewController along with a window for the app to be displayed in. This leads to problems when launching the app on the CarPlay-client first, since CarPlay does not require a rootViewController or a window to display its views.
The key to solving this problem is to split the app initialization logic into PhoneScene and CarScene (which are both subclasses of UIResponder) and only run the code required to set up the React Native bridge in the AppDelegate. We can achieve this by not calling the super-method in application:didFinishLaunchingWithOptions: but instead create and call a
custom init method.
Prior to React Native 0.74 this wasn't a problem, since all methods needed for setup were publicly exposed.
Starting with React Native 0.74, the root view is created via RCTRootViewFactory with no way of instantiating one from the custom initialization routine in App Delegate.
How do you plan to support Application Scene Delegates in the future?
Are there any options to create a RCTRootViewFactory without patching the header file as described here?
Would it be problematic to expose createRCTRootViewFactory in the header, making it accessible from the App Delegate?
Steps to reproduce
Try setting up a RN 0.74 or 0.75 app via application scene delegates
React Native Version
0.74
Affected Platforms
Runtime - iOS
Output of npx react-native info
irrelevant
Stacktrace or Logs
none
Reproducer
none
Screenshots and Videos
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
RCTAppDelegate.mm、特に createRCTRootViewFactory とエントリーポイントの AppDelegate application:didFinishLaunchingWithOptions: から始めます。issue に記載されている PhoneScene と CarScene の初期化を確認し、その後、maintainers とサポート対象の公開 API および受け入れ条件を明確にします。完了時には、不適切な phone root view や window を必要とせずに、Application Scene Delegates 向けのサポート対象の React Native 初期化パスを提供できる状態にします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- ios, react-native
- 領域
- mobile
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 活発
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 30/100