From 7f8d9f0356c7fd2c2b206fb6d55cc7caedc6735d Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Mon, 19 Feb 2024 05:30:29 -0800 Subject: [PATCH] Hook the default-app-setup OnLoad.cpp file with the cxxModuleProvider from RNCLI (#43049) Summary: This connects the OnLoad.cpp file used by OSS apps with the `rncli_cxxModuleProvider`. This method is created by the CLI and takes care of querying all the TM CXX Modules discovered and returning them. This PR is currently waiting on https://github.com/react-native-community/cli/pull/2296 Changelog: [Internal] [Changed] - Hook the default-app-setup OnLoad.cpp file with the cxxModuleProvider from RNCLI Reviewed By: cipolleschi Differential Revision: D53812109 --- .../cmake-utils/default-app-setup/OnLoad.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp b/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp index d206b123ad44bb..56a38374370ab6 100644 --- a/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp @@ -62,8 +62,16 @@ void registerComponents( std::shared_ptr cxxModuleProvider( const std::string& name, const std::shared_ptr& jsInvoker) { - // Not implemented yet: provide pure-C++ NativeModules here. - return nullptr; + // Here you can provide your CXX Turbo Modules coming from + // either your application or from external libraries. The approach to follow + // is similar to the following (for a module called `NativeCxxModuleExample`): + // + // if (name == NativeCxxModuleExample::kModuleName) { + // return std::make_shared(jsInvoker); + // } + + // And we fallback to the CXX module providers autolinked by RN CLI + return rncli_cxxModuleProvider(name, jsInvoker); } std::shared_ptr javaModuleProvider(