Fix remaining missing debugger build flags for open source builds (#54774)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54774

NOTE: This diff is a backport of https://github.com/facebook/react-native/pull/54770, where on the `0.83-stable` release branch, Network support for React Native DevTools was in a broken state under the open source build systems.

### Cause

Network debugging support depends a number of `REACT_NATIVE_DEBUGGER_ENABLED` preprocessor flags, which we use to compile away any overhead in production builds.

As we unfortunately use a total of **4 native build systems** today (with Buck 2 internally and primarily), the registration of these flags was missing across a number of native ObjC/C++ packages, which are now fixed with this PR.

- D87864636 aimed to address this as we weren't seeing the Network panel at all. However, it was insufficient, as it has only partially enabled network features between platforms.

### This diff

Add missing preprocessor flags in:

- Android:
	- `src/main/jni/react/devsupport/CMakeLists.txt`
	- `src/main/jni/CMakeLists.txt`
- iOS (Pods):
	- `React-jsinspectorNetwork`
- iOS (`Package.swift`):
	- `Libraries/Network`

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D88284345

fbshipit-source-id: 8ff0b424834b40ed186432f630287abe5fe8b997
This commit is contained in:
Alex Hunt authored and meta-codesync[bot] committed 2025-12-04 08:18:26 -08:00
1 parent 3084224bec
commit 0874746076
4 files changed
+21 -1

No files matched your search

+5 -1
View File
@@ -593,7 +593,11 @@ let reactRCTBlob = RNTarget(
let reactRCTNetwork = RNTarget(
name: .reactRCTNetwork,
path: "Libraries/Network",
dependencies: [.yoga, .jsi, .reactTurboModuleCore]
dependencies: [.yoga, .jsi, .reactTurboModuleCore],
defines: [
CXXSetting.define("REACT_NATIVE_DEBUGGER_ENABLED", to: "1", .when(configuration: BuildConfiguration.debug)),
CXXSetting.define("REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY", to: "1", .when(configuration: BuildConfiguration.debug)),
]
)
/// React-RCTVibration.podspec
@@ -338,3 +338,10 @@ target_include_directories(reactnative
$<TARGET_PROPERTY:uimanagerjni,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:yoga,INTERFACE_INCLUDE_DIRECTORIES>
)
if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED)
target_compile_options(reactnative PRIVATE
-DREACT_NATIVE_DEBUGGER_ENABLED=1
-DREACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1
)
endif ()
@@ -23,3 +23,10 @@ target_link_libraries(react_devsupportjni
react_networking)
target_compile_reactnative_options(react_devsupportjni PRIVATE)
if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED)
target_compile_options(react_devsupportjni PRIVATE
-DREACT_NATIVE_DEBUGGER_ENABLED=1
-DREACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1
)
endif ()
@@ -58,9 +58,11 @@ class ReactNativePodsUtils
def self.set_gcc_preprocessor_definition_for_debugger(installer)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED=1", "React-jsinspector", :debug)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED=1", "React-jsinspectornetwork", :debug)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED=1", "React-RCTNetwork", :debug)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED=1", "React-networking", :debug)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1", "React-jsinspector", :debug)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1", "React-jsinspectornetwork", :debug)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1", "React-RCTNetwork", :debug)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1", "React-networking", :debug)
end