Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41956
By default, generated Cxx sources for components all end up in same directory. However the include declarations in them look like this:
```
#include <react/renderer/components/${libraryName}/ShadowNodes.h>
```
And not like this:
```
#include "ShadowNodes.h"
```
This works fine with Buck because it supports header prefixes.
To get this working with CocoaPods we define additional `HEADER_SEARCH_PATHS` for our `React-Codegen` pod.
This approach will not work if we want to generate code at the library level and check in the artifacts. That's because we don't have control over the Podspec there, and can't inject those additional `HEADER_SEARCH_PATHS`.
This diff adds the `headerPrefix` argument to the codegen entry point. It is `react/renderer/components/${libraryName}` by default, but can become empty if we want to generate code at the library level, and don't want to deal with this nested header structure.
*Note:* `RNCodegen` runs all the generators [in a loop](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/generators/RNCodegen.js#L263-L275), assuming that the all have same function signature So I had to add the `headerPrefix` argument to all the generators, even to the ones that don't really need it.
Changelog: [General][Added] - Introduce "headerPrefix" codegen option.
Reviewed By: zeyap
Differential Revision: D51811596
fbshipit-source-id: c5c3e1e571c7c4ea2f5354eb9a7b0df6b917fc0c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41655
This diff adds support for checked-in codegen artifacts for libraries.
It introduces a new property to `codegenConfig`, called `includesGeneratedCode`. If codegen sees `includesGeneratedCode: true` in a project's dependency, it assumes that the library has codegen artifacts in it, and will not generate any code.
Changelog: [General][Added] - Introduce "codegenConfig.includesGeneratedCode" property.
Reviewed By: cipolleschi
Differential Revision: D51207265
fbshipit-source-id: 65855fd846e24a53cb18008839121e99eeb59309
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41661
This aligns the Kotlin version used inside fbsource to the one used for React Native GitHub
Changelog:
[Internal] [Changed] - Kotlin to 1.8.22
Reviewed By: NickGerleman
Differential Revision: D51587726
fbshipit-source-id: 5f985bd50c7688e4d369184b79dbf1bdc799876e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41621
Currently, if you have a dependency that is alphabetically smaller than `app`, it's evaluation will happen before `app`.
This means that the namespace auto-discovery and the JVM toolchain configuration won't be working and the project will fail to buid.
This fixes it by introducing a root-project Gradle Plugin that takes care of enforcing the evaluation order on the `app` project.
Fixes#41620
Changelog:
[Android] [Fixed] - Fix projects being broken on dependencies starting with `a..`
Reviewed By: huntie
Differential Revision: D51547294
fbshipit-source-id: 65df7149548b7087dd8928e556fb803b3baf7b79
Summary:
CxxReactPackage is supposed to be the way apps register C++-only turbo modules with React Native.
Applications are meant to subclass this jni::HybridObject.
Since this is a jni::HybridObject, applications are meant to create this CxxReactPackage in java, and initialize it with java dependencies.
React Native will reach into its c++ part, and use it create C++-only turbo modules.
NOTE: This is a **temporary** abstraction meant to unblock the stable API effort of removing the turbomodulemanagerdelegate builder from ReactHostDelegate:
https://www.internalfb.com/code/fbsource/[e7efced3018f6178b7187a2358f3b76d40e2b43c]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostDelegate.kt?lines=50-51
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D51166523
fbshipit-source-id: 51a22411239fbba32f3a70cc363e59947c2782dc
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41485
Now that React-Hermes does not depends on folly::Futures anymore, we can safely delete the `libevent` dependency.
This will speedup the pod install step and potentially also the bundle size (to be tested)
## Changelog
[Android][Removed] - Remove libevent dependency
Reviewed By: javache
Differential Revision: D51319583
fbshipit-source-id: 155cc3632b005074c43565e7281c9873ab046f0d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41175
This will make sure that if you specify a maven local folder with `react.internal.mavenLocalRepo`
you're not attempting to fetch artifacts from Maven Central.
Changelog:
[Internal] [Changed] - Do not attempt to query Maven Central if project has react.internal.mavenLocalRepo
ignored-github-export-checks
bypass-github-export-checks
Reviewed By: mdvacca
Differential Revision: D50600815
fbshipit-source-id: f429c2ae9d7204e4aa2cb29357983c0dc3a1aab6
Summary:
As stated here https://github.com/react-native-community/discussions-and-proposals/issues/671 React Native 0.73 will depend on Android Gradle Plugin (AGP) 8.x which requires all libraries to specify a namespace in their build.gradle file, even though this issue was raised many months ago, lots of libraries have not been updated and don't specify a `namespace` inside their build.gradle files
## Changelog:
[ANDROID] [CHANGED] - Ensure namespace is specified for all the 3rd party libraries
Pull Request resolved: https://github.com/facebook/react-native/pull/41085
Test Plan:
Run RNGP tests and test building rn-tester after doing the following procedure
1. Remove `namespace "com.facebook.react"` from react-native/packages/react-native/ReactAndroid/build.gradle
2. Add `package="com.facebook.react"` to react-native/packages/react-native/ReactAndroid/src/main/AndroidManifest.xml
3. Build rn-tester
Also tested this using [BareExpo](https://github.com/expo/expo/tree/main/apps/bare-expo) with AGP 8.1.1 and all libraries that were missing the `namespace` compiled correctly
Reviewed By: cipolleschi
Differential Revision: D50556667
Pulled By: cortinico
fbshipit-source-id: 3d75ec0a8b82427ff0ede89aa7bc58b28b288945
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39540
This simplifies the use of Codegen when creating dev builds of `rn-tester` in the monorepo. It now runs from source for this internal scenario, and this package is now built using the shared monorepo build setup.
Changes:
- Migrate `packages/react-native-codegen` to the shared `yarn build` setup.
- Update package to use `"exports"` field and wrap entry point modules with `babel-register` (NOTE: This is only required for each entry point internally used in the monorepo).
- Fixup small Flow syntax quirks that fail under `hermes-parser`.
- Remove `BuildCodegenCLITask` task from Android build.
- Remove Codegen `build.sh` call from iOS build, use `require.resolve` for `combine-js-to-schema-cli.js` entry point.
Externally significant FYIs:
- `react-native/codegen` is converted to use the `"exports"` field — it should export all `.js` files, as before.
- `codegenPath` is now ignored and marked as deprecated on `ReactExtensions.kt`.
NOTE: TypeScript auto-generation is not yet enabled on this package, since it uses CommonJS `module.exports` syntax (unsupported by `flow-api-translator`).
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D49370200
fbshipit-source-id: 992913155169912ea1a3cb24cb26efbd3f783058
Summary:
Fix https://github.com/facebook/react-native/issues/40560
## Changelog:
[ANDROID] [FIXED] - Ensure that `configureJavaToolChains` is only executed once during configuration
Pull Request resolved: https://github.com/facebook/react-native/pull/40757
Test Plan:
- Create a fresh `react-native@0.73.0-rc.1` project
- Install `react-native-webview`
- Apply [this patch](https://github.com/react-native-webview/react-native-webview/pull/3175/files) for `react-native-webview` (caused by another issue https://github.com/facebook/react-native/issues/40559)
- Edit `android/gradle.properties` and set `newArchEnabled` to true
- Build application
- (Expected) Application fail to build
- Apply this PR
- (Expected) Application build successfully
**Additional explanation:**
According to the implementation of `configureJavaToolChains`, all the subprojects (both the app and the libraries) will have their toolchains setup in one execution of the method. Therefore, it is okay for the method to be invoked only when configuring the plugin for the app.
On the other hand, invoking the method for more than one time will cause the issue stated in https://github.com/facebook/react-native/issues/40560.
Reviewed By: cipolleschi
Differential Revision: D50361871
Pulled By: cortinico
fbshipit-source-id: bd5e18df97988122788d0482dba954e517a0cb5c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40935
This is scheduled to land in 0.74, so I'm removed the native integration as this is not needed anymore.
The only thing I left is a stub class to ease the migration out of `ReactNativeFlipper`.
Changelog:
[Android] [Removed] - Remove ReactNative/Flipper Integration
Reviewed By: mdvacca, huntie, cipolleschi
Differential Revision: D50259817
fbshipit-source-id: 28427425340896635607202cd78936f6030e78e0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40939
Currently some libs on RN 0.73 are broken as the default for Build Config generation changed
from true to false since AGP 8.x. This reverts the behavior to the old flag.
Closes#40791Closes#40559
Changelog:
[Internal] [Changed] - Make sure buildConfig is turned on for all the 3rd party libraries
Reviewed By: mdvacca
Differential Revision: D50270382
fbshipit-source-id: 02dcb031c577f65be2f41d9da0334c1b3d89e4c5
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39959
We're still accessing project.buildDir which will be removed in Gradle 9.0
I'm cleaning it up here.
Changelog:
[Internal] [Changed] - Fix compilation warnings introduced by Gradle 8.4
Reviewed By: yungsters
Differential Revision: D50016573
fbshipit-source-id: de7a725f61b503f08991ebf85b9a002cefab221a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39960
This is our usual round of bumps just after the branch cut.
Changelog:
[Android] [Changed] - Bump Gradle to 8.4
Reviewed By: yungsters
Differential Revision: D50016574
fbshipit-source-id: 781eb906f6b12f76f673e38bdcf099c9b7cefade
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39634
Running build from source as suggested here:
https://reactnative.dev/contributing/how-to-build-from-source
is currently broken for nightly versions (and for 0.73).
This fixes it by:
- Fixing the import of the Gradle Version Catalog
- Actually adding the Gradle version catalog to the NPM package
- Fixing how the build Codegen CLI task is invoked for build-from-source
- Updating the search directories for codegenDir/reactNativeDir from build-from-source
Changelog:
[Internal] [Fixed] - Unblock build-from-source on nightlies
Reviewed By: cipolleschi
Differential Revision: D49562595
fbshipit-source-id: 9594b7d947569d41c461a7e8287d3ae68fb87b98
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39619https://github.com/facebook/react-native/pull/39603 unintentionally changed our Gradle distribution type in `gradle.properties` to `bin`. This changes it back to `all` while preserving the upgrade to 8.3.
Generated with
```
./gradlew wrapper --gradle-version=8.3 --distribution-type all
```
Changelog:
[Internal][Changed] Revert Gradle distribution type to ‘all’
Reviewed By: NickGerleman
Differential Revision: D49569492
fbshipit-source-id: fc5b2c8a2c2cea455ed5bd0dbd6743d34b527c9b
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39502
This diff adds the parsing of the package.json to retrieve the version of react native and it matches it against a regex to decide whether to enable or not the New Architecture.
This change depends on [this CLI's PR](https://github.com/react-native-community/cli/pull/2076).
## Changelog:
[Android][Added] - Parse RN Version to decide whether to enable the New Arch or not.
Reviewed By: cortinico
Differential Revision: D49270012
fbshipit-source-id: 5164a1ddd26f1822c0d717a7a9e2416ec38d78a2
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39501
This change introduce a new model to parse the React Native package.json.
The objects are not connected but they will be used in the next diff
## Changelog:
[Android][Added] - Add a couple of types in the RNGP for json parsing.
Reviewed By: cortinico
Differential Revision: D49270044
fbshipit-source-id: 42a855bb85a5f8e1b1249ab3ebee974ce3fb93fd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39392
This fixes a warning that would fire for all the users on 0.73 and is not actionable in any form: https://issuetracker.google.com/issues/295235385
Changelog:
[Internal] [Changed] - Bump AGP to 8.1.1
Reviewed By: luluwu2032
Differential Revision: D49155866
fbshipit-source-id: 05201b834d00b018f8680d74fe4a40884a8c5eb9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38886
This change introduces a property called `react.internal.useHermesNightly`
This allows users building RN-Tester or just ReactAndroid to fetch Hermes from the latest
nightly, without having to build it from source.
The change could be useful to speedup local development, but it should not be enabled on CI or when doing releases.
Changelog:
[Internal] [Changed] - Introduce react.internal.useHermesNightly
Reviewed By: mdvacca, cipolleschi
Differential Revision: D48188769
fbshipit-source-id: cb4330cb9082e9db0c7ba82e48b2d10030637353
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38885
We do have several Gradle Properties that are used to configure the build.
I've refactored them all and moved them inside the PropertyUtils file:
https://github.com/facebook/react-native/blob/main/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt
Specifically properties should be 'scoped' under `react.` if public, and `react.internal.` if for internal usage.
Property that I cleaned up are:
- REACT_NATIVE_MAVEN_LOCAL_REPO becomes react.internal.mavenLocalRepo
- REACT_WINDOWS_BASH becomes react.internal.windowsBashPath
- GROUP becomes react.internal.publishingGroup
I've also added support for scoping for public properties with backward compat (so both the scoped and unscoped properties are accepted):
- react.newArchEnabled
- react.hermesEnabled
- react.nativeArchitectures
Changelog:
[Android] [Changed] - Cleanup and scope all the Gradle Properties
Reviewed By: mdvacca
Differential Revision: D48188310
fbshipit-source-id: 1a92d31105270a4c2f80029b7d36bcb33916d0fb
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38946
I'm doing another pass of moving all the various version numbers of the Gradle Plugin inside the `[plugins]` section of the version catalog.
Changelog:
[Internal] [Changed] - Consolidate Gradle Plugin versions inside the version catalog
Reviewed By: mdvacca
Differential Revision: D48233147
fbshipit-source-id: afd12e5377d2d88c53cef4e6913b5c49b3da5bbb
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38927
I've done a pass and fixed most of the warnings for Gradle 9:
- project.buildDir is deprecated in favor of project.layout.buildDirectory
- I've updated 3rd party Gradle Plugins that we depend on
There are still two warnings which are outside of our control:
1. One is inside AGP and will be fixed with AGP 8.2 - Source https://issuetracker.google.com/issues/279306626
2. Another one is inside nexus-publish and should ideally be fixed by 2.0 https://github.com/gradle/gradle/issues/25206 Will bump the release once it's out
Changelog:
[Internal] [Changed] - Fix warnings for Gradle 9
Reviewed By: mdvacca
Differential Revision: D48231760
fbshipit-source-id: 27d704324ea33cfc8aa0164fa437b80aab425960
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38882
This turns on local caching for Gradle builds.
From now on, some of the tasks of the build will be cached inside the `.gradle` folder.
This will benefit 'clean builds' and builds happening after branch/context switch.
CI will also benefit from this improvement as we're storing the cache folder on CircleCI.
After this we'll have to follow-up and enabling `Cacheable` on each of our task as
they're currently all disabled.
Changelog:
[Internal] [Changed] - Enable local caching for Gradle
Reviewed By: mdvacca
Differential Revision: D48187656
fbshipit-source-id: 25734ed692a69874721e86c50498b075af0fda19
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38903
Currently Android is not rebuilding the CLI if its content changes. This is a bug.
It's resolution is a bit more complicated as we do have various `buildCodegenCLI` tasks, also in user projects.
I've removed the tasks from the user projects, as they're practically not needed (users always consume a prebuilt codegen).
And I've also updated the setup to have only one `buildCodegenCLI` in the ReactAndroid project.
This allows us to ensure the job executes only once and has correct input/outputs.
Changelog:
[Internal] [Changed] - Fix compilation avoidance bug with buildCodegenCLI
Reviewed By: mdvacca
Differential Revision: D48199157
fbshipit-source-id: ba3be6a0ca959ac4e1240e8feb99b8274e4e2b46
Summary:
As we had version numbers scattered all over the places, I'm consolidating them to use a version catalog: https://docs.gradle.org/current/userguide/platforms.html
## Changelog:
[INTERNAL] - Use version catalog to consolidate versions for JVM dependencies
Pull Request resolved: https://github.com/facebook/react-native/pull/38836
Test Plan: CI
Reviewed By: cipolleschi
Differential Revision: D48150285
Pulled By: cortinico
fbshipit-source-id: 83a1867aace5395d9a10fadd6c6ab11c31fa14b5
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38638
A new stable version of Android Gradle Plugin has just been released which I'm bumping over here, and applying all the required changes.
Changelog:
[Internal] [Changed] - Bump AGP to 8.1.0
Reviewed By: cipolleschi
Differential Revision: D47798273
fbshipit-source-id: 57672b10444ffb6079aa5881ff09d033d2a5e895
Summary:
I was getting the following error when trying to run RN Tester on Android.
```
A problem occurred configuring project ':packages:react-native:ReactAndroid'.
> Could not determine the dependencies of task ':react-native-gradle-plugin:compileKotlin'.
> No matching toolchains found for requested specification: {languageVersion=17, vendor=any, implementation=vendor-specific} for MAC_OS on aarch64.
> No locally installed toolchains match and toolchain download repositories have not been configured.
```
This is fixed by adding the `org.gradle.toolchains.foojay-resolver-convention` plugin in settings.gradle, this was done already for the root one, but not in the one in `react-native-gradle-plugin`.
## Changelog:
[INTERNAL] [FIXED] - Add missing toolchains plugin in react-native-gradle-plugin
Pull Request resolved: https://github.com/facebook/react-native/pull/38292
Test Plan: Build RN Tester on android
Reviewed By: mdvacca
Differential Revision: D47371772
Pulled By: cortinico
fbshipit-source-id: 8eaa5de9559720a7b37d11b3ddceb5fb84753a40
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37688
This moves the `ReactNativeFlipper` classes used to configure Flipper on Android from the template to
a separate Gradle artifact that will be published under the coordinates:
```
com.facebook.react:flipper-integration:0.73.x
```
This reduces the footprint of Flipper on the app template and makes easier for user on 0.73 to migrate
to Kotlin (as they will now have to migrate only 2 files rather than 4).
Changelog:
[Android] [Changed] - Move Flipper integration to a separate Gradle module inside `ReactAndroid`
Reviewed By: huntie
Differential Revision: D46441588
fbshipit-source-id: e197f29b7386b52091b8d38ed09bbd8f74a997df
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37019
This bumps the version of AGP to the latest stable.
There was a breaking change in how buildConfig are built which I had to handle.
This also requires a bump of RNGP to work correctly.
Moreover, we now required Java 17 to build Android apps (as that's a AGP requirement).
Changelog:
[Android] [Changed] - Java to 17 and AGP to 8.0.2
Reviewed By: cipolleschi
Differential Revision: D45178748
fbshipit-source-id: 0f302e1f2f2ee56bd3566202fbb5ef67c9b220db
Summary:
Just keeping our Gradle version up to date.
Changelog:
[Internal] [Changed] - Bump Gradle to 8.1.1
Reviewed By: yungsters
Differential Revision: D46769069
fbshipit-source-id: b79ae35473f40e821cf6a1b8e094e33d1b1a44d7
Summary:
Limit diagnostics width output by `hermesc` as they may cause slowdowns or even crashes in Gradle/Xcode when a minified bundle is used as input. This occurs because Hermes is unable to determine the terminal width when executed by Gradle/Xcode, and falls back to "unlimited". If the input is a minified bundle, Hermes will output the whole bundle for each warning.
See issues filed:
- https://github.com/microsoft/rnx-kit/issues/2416
- https://github.com/microsoft/rnx-kit/issues/2419
- https://github.com/microsoft/rnx-kit/issues/2424
## Changelog:
[GENERAL] [FIXED] - Limit diagnostics width output by `hermesc`
Pull Request resolved: https://github.com/facebook/react-native/pull/37531
Test Plan: See listed issues for repros.
Reviewed By: cipolleschi
Differential Revision: D46102686
Pulled By: cortinico
fbshipit-source-id: 1b821cad7ef0d561a5e1c13a7aedf9b10164620a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37494
I'm adding some unit tests to this function that got recently added to support TvOS
Changelog:
[Internal] [Changed] - Add tests for getDependencySubstitutions
Reviewed By: cipolleschi
Differential Revision: D46029402
fbshipit-source-id: 6099242fe9e18f1a612124bc784f90047b4ee286
Summary:
For 3rd party libraries to work with a React Native fork (such as the TV repo) that uses a different Maven group for `react-android` and `hermes-android` artifacts, an additional dependency substitution is required.
## Changelog:
[Android][fixed] RNGP dependency substitutions for fork with different Maven group
Pull Request resolved: https://github.com/facebook/react-native/pull/37445
Test Plan:
- Manual tested with an existing project
- Unit tests pass
Reviewed By: rshest, dmytrorykun
Differential Revision: D45948901
Pulled By: cortinico
fbshipit-source-id: 4151a1d3616172a92c68812c3a0034c98b330d67