Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functions to check whether the New Arch is enabled at runtime (#4…
…2090) Summary: Pull Request resolved: #42090 This change is the last pieces of removing `RCT_NEW_ARCH_ENABLED` flag and defragmenting the build setup on iOS. Before, 3rd party libraries had to use the `#if RCT_NEW_ARCH_ENABLED` flag to compile in and out segment of code depending on whether the new architecture was turned on or not. After the recent changes, we can now expose the `RCTIsNewArchEnabled()` function to read whether the New Arch is enabled at runtime or not. This will promote better code practices as we can replace ugly, compile time, `#if-#else-#endif`s with a more readable and natural regular obj-c code. We can also use inheritance to have different implementation based on the architecture. To use the new function, a 3rd party library have to: 1. `#import <React/RCTUtils.h>` (if they use the `install_modules_dependencies` function we provide, they can already do it) 2. invoke `RCTIsNewArchEnabled()` which returns a BOOL. 3. implement the code accordingly, depending on the New arch state. **Note:** we implemented also the `RCTSetNewArchEnabled` function. This is called as soon as React Native is initialized in the `RCTAppDelegate`. The method can be called only once per React Native lifecycle. Subsequent calls to that method are ignored. ## Changelog: [iOS][Added] - Added the `RCTIsNewArchEnabled()` to check whether the New Arch is enabled at runtime. Reviewed By: cortinico Differential Revision: D52445107 fbshipit-source-id: 1b432832912d33c85687b4c37f9e360ce9699f59
- Loading branch information