Skip to content

Commit 0874746

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Fix remaining missing debugger build flags for open source builds (#54774)
Summary: Pull Request resolved: #54774 NOTE: This diff is a backport of #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
1 parent 3084224 commit 0874746

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

packages/react-native/Package.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,11 @@ let reactRCTBlob = RNTarget(
593593
let reactRCTNetwork = RNTarget(
594594
name: .reactRCTNetwork,
595595
path: "Libraries/Network",
596-
dependencies: [.yoga, .jsi, .reactTurboModuleCore]
596+
dependencies: [.yoga, .jsi, .reactTurboModuleCore],
597+
defines: [
598+
CXXSetting.define("REACT_NATIVE_DEBUGGER_ENABLED", to: "1", .when(configuration: BuildConfiguration.debug)),
599+
CXXSetting.define("REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY", to: "1", .when(configuration: BuildConfiguration.debug)),
600+
]
597601
)
598602

599603
/// React-RCTVibration.podspec

packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,10 @@ target_include_directories(reactnative
338338
$<TARGET_PROPERTY:uimanagerjni,INTERFACE_INCLUDE_DIRECTORIES>
339339
$<TARGET_PROPERTY:yoga,INTERFACE_INCLUDE_DIRECTORIES>
340340
)
341+
342+
if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED)
343+
target_compile_options(reactnative PRIVATE
344+
-DREACT_NATIVE_DEBUGGER_ENABLED=1
345+
-DREACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1
346+
)
347+
endif ()

packages/react-native/ReactAndroid/src/main/jni/react/devsupport/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ target_link_libraries(react_devsupportjni
2323
react_networking)
2424

2525
target_compile_reactnative_options(react_devsupportjni PRIVATE)
26+
27+
if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED)
28+
target_compile_options(react_devsupportjni PRIVATE
29+
-DREACT_NATIVE_DEBUGGER_ENABLED=1
30+
-DREACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1
31+
)
32+
endif ()

packages/react-native/scripts/cocoapods/utils.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ def self.set_gcc_preprocessor_definition_for_React_hermes(installer)
5858

5959
def self.set_gcc_preprocessor_definition_for_debugger(installer)
6060
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED=1", "React-jsinspector", :debug)
61+
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED=1", "React-jsinspectornetwork", :debug)
6162
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED=1", "React-RCTNetwork", :debug)
6263
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED=1", "React-networking", :debug)
6364
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1", "React-jsinspector", :debug)
65+
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1", "React-jsinspectornetwork", :debug)
6466
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1", "React-RCTNetwork", :debug)
6567
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1", "React-networking", :debug)
6668
end

0 commit comments

Comments
 (0)