From fd06942dc5ae1ef4a08b5763179c5ecdccce4733 Mon Sep 17 00:00:00 2001 From: Rodolfo Silva Date: Sun, 24 May 2026 18:48:49 -0300 Subject: [PATCH 1/2] fix(android): forward REACT_NATIVE_MINOR_VERSION to JNI build On RN >= 0.84, react-native-worklets' Defs.h uses REACT_NATIVE_MINOR_VERSION to select between facebook::react::JSBigString (new, non-deprecated) and facebook::react::BigStringBuffer (deprecated). Worklets defines this macro in its own CMake context, so it never reaches consumers that include the worklets headers from a separate CMake project. Without the macro the preprocessor treats it as 0, picks the deprecated BigStringBuffer alias, and -Werror,-Wdeprecated-declarations turns the warning into a hard build failure on RN 0.85. Resolve the React Native minor version from react-native/package.json via Node (same approach worklets uses internally) and forward it as a private compile definition to the codegen target so the worklets headers select the correct alias. Fails fast with a clear error if Node resolution fails. --- android/src/main/jni/CMakeLists.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt index 4fac882..b02b55b 100644 --- a/android/src/main/jni/CMakeLists.txt +++ b/android/src/main/jni/CMakeLists.txt @@ -34,6 +34,25 @@ if(NOT DEFINED REACT_NATIVE_WORKLETS_DIR OR "${REACT_NATIVE_WORKLETS_DIR}" STREQ get_filename_component(REACT_NATIVE_WORKLETS_DIR "${_worklets_pkg_json}" DIRECTORY) endif() +# Resolve React Native minor version so worklets headers pick the correct +# JSBigStringBuffer alias (deprecated on RN >= 0.84). +if(NOT DEFINED REACT_NATIVE_MINOR_VERSION) + execute_process( + COMMAND "${NODE_BINARY}" -p "require('react-native/package.json').version.split('.')[1]" + WORKING_DIRECTORY "${PROJECT_ROOT_DIR}/.." + OUTPUT_VARIABLE REACT_NATIVE_MINOR_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE _rn_minor_res + ERROR_QUIET + ) + if(NOT _rn_minor_res EQUAL 0 OR "${REACT_NATIVE_MINOR_VERSION}" STREQUAL "") + message(FATAL_ERROR + "Failed to resolve React Native minor version with Node from '${PROJECT_ROOT_DIR}/..'. " + "Set REACT_NATIVE_MINOR_VERSION or NODE_BINARY explicitly." + ) + endif() +endif() + file(GLOB LIB_CUSTOM_SRCS CONFIGURE_DEPENDS *.cpp ${LIB_COMMON_DIR}/*.cpp) file(GLOB LIB_CODEGEN_SRCS CONFIGURE_DEPENDS ${LIB_ANDROID_GENERATED_JNI_DIR}/*.cpp ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}/*.cpp) @@ -86,4 +105,10 @@ target_include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) +target_compile_definitions( + ${LIB_TARGET_NAME} + PRIVATE + REACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} +) + target_compile_reactnative_options(${LIB_TARGET_NAME} PUBLIC) From 00274d46161dc94216be7aa77f5ca6843e07ebaf Mon Sep 17 00:00:00 2001 From: Rodolfo Silva Date: Thu, 18 Jun 2026 17:10:44 -0300 Subject: [PATCH 2/2] fix(android): hoist NODE_BINARY above worklets dir resolution --- android/src/main/jni/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt index b02b55b..9556e21 100644 --- a/android/src/main/jni/CMakeLists.txt +++ b/android/src/main/jni/CMakeLists.txt @@ -9,12 +9,12 @@ set(LIB_COMMON_DIR ${LIB_ANDROID_DIR}/../cpp) set(LIB_ANDROID_GENERATED_JNI_DIR ${LIB_ANDROID_DIR}/build/generated/source/codegen/jni) set(LIB_ANDROID_GENERATED_COMPONENTS_DIR ${LIB_ANDROID_GENERATED_JNI_DIR}/react/renderer/components/${LIB_LITERAL}) +set(NODE_BINARY "node" CACHE STRING "Path to Node.js binary") + # Resolve path to react-native-worklets. set(REACT_NATIVE_WORKLETS_DIR "" CACHE PATH "Path to react-native-worklets root directory") if(NOT DEFINED REACT_NATIVE_WORKLETS_DIR OR "${REACT_NATIVE_WORKLETS_DIR}" STREQUAL "") - set(NODE_BINARY "node" CACHE STRING "Path to Node.js binary") - execute_process( COMMAND "${NODE_BINARY}" -p "require.resolve('react-native-worklets/package.json')" WORKING_DIRECTORY "${PROJECT_ROOT_DIR}/.."