Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to check whether the New Arch is enabled at runtime #42090

Closed
wants to merge 2 commits into from

Conversation

cipolleschi
Copy link
Contributor

Summary:
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-#endifs 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.

Differential Revision: D52445107

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 28, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52445107

@analysis-bot
Copy link

analysis-bot commented Dec 28, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 16,577,959 +5
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 19,955,043 +1
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: af8c56a
Branch: main

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52445107

cipolleschi added a commit to cipolleschi/react-native that referenced this pull request Dec 28, 2023
…cebook#42090)

Summary:

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.

Differential Revision: D52445107
cipolleschi added a commit to cipolleschi/react-native that referenced this pull request Dec 28, 2023
…cebook#42090)

Summary:

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.

Differential Revision: D52445107
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52445107

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52445107

cipolleschi added a commit to cipolleschi/react-native that referenced this pull request Jan 2, 2024
…cebook#42090)

Summary:

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
cipolleschi added a commit to cipolleschi/react-native that referenced this pull request Jan 2, 2024
…cebook#42090)

Summary:

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
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52445107

Summary:

This change adds an extra function to customise the RootView in both Bridge and Bridgeless mode.
To nudge users in a migration, we also add a warning message for next version that should push our users to migrate away from the old implementation to the new one.
*The Warning is shown ONLY when the user do customise the rootView*. For users which were not customising the Root View, the warning will not appear.

The documentation of the new method plus the warning should guide the users toward the right migration path.

## Changelog
[iOS][Added] - Added the customiseRootView method which is called in both bridge and bridgeless. Added also a warning for 0.74 with instructions on how to migrate.

Reviewed By: cortinico

Differential Revision: D52442598
…cebook#42090)

Summary:

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
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D52445107

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 2, 2024
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in f1a7f08.

Othinn pushed a commit to Othinn/react-native that referenced this pull request Jan 9, 2024
…cebook#42090)

Summary:
Pull Request resolved: facebook#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants