Skip to content

Commit 9741b2a

Browse files
committed
fix: missing symbols in rn-tester test builds
1 parent bf04df5 commit 9741b2a

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ def self.add_search_path_to_result(result, base_path, additional_paths, include_
661661

662662
def self.add_ndebug_flag_to_pods_in_release(installer)
663663
ndebug_flag = " -DNDEBUG"
664+
react_native_debug_flag = " -DREACT_NATIVE_DEBUG=0"
664665

665666
installer.aggregate_targets.each do |aggregate_target|
666667
aggregate_target.xcconfigs.each do |config_name, config_file|
@@ -670,6 +671,9 @@ def self.add_ndebug_flag_to_pods_in_release(installer)
670671
end
671672
self.add_flag_to_map_with_inheritance(config_file.attributes, 'OTHER_CPLUSPLUSFLAGS', ndebug_flag);
672673
self.add_flag_to_map_with_inheritance(config_file.attributes, 'OTHER_CFLAGS', ndebug_flag);
674+
# explicitly set REACT_NATIVE_DEBUG to 0 for Release builds to ensure consistent compilation
675+
self.add_flag_to_map_with_inheritance(config_file.attributes, 'OTHER_CPLUSPLUSFLAGS', react_native_debug_flag);
676+
self.add_flag_to_map_with_inheritance(config_file.attributes, 'OTHER_CFLAGS', react_native_debug_flag);
673677

674678
xcconfig_path = aggregate_target.xcconfig_path(config_name)
675679
config_file.save_as(xcconfig_path)
@@ -684,6 +688,38 @@ def self.add_ndebug_flag_to_pods_in_release(installer)
684688
end
685689
self.add_flag_to_map_with_inheritance(config.build_settings, 'OTHER_CPLUSPLUSFLAGS', ndebug_flag);
686690
self.add_flag_to_map_with_inheritance(config.build_settings, 'OTHER_CFLAGS', ndebug_flag);
691+
# explicitly set REACT_NATIVE_DEBUG to 0 for Release builds to ensure consistent compilation
692+
self.add_flag_to_map_with_inheritance(config.build_settings, 'OTHER_CPLUSPLUSFLAGS', react_native_debug_flag);
693+
self.add_flag_to_map_with_inheritance(config.build_settings, 'OTHER_CFLAGS', react_native_debug_flag);
694+
end
695+
end
696+
end
697+
698+
def self.add_react_native_debug_flag_to_pods_in_debug(installer)
699+
react_native_debug_flag = " -DREACT_NATIVE_DEBUG=1"
700+
701+
installer.aggregate_targets.each do |aggregate_target|
702+
aggregate_target.xcconfigs.each do |config_name, config_file|
703+
is_debug = aggregate_target.user_build_configurations[config_name] == :debug
704+
unless is_debug
705+
next
706+
end
707+
self.add_flag_to_map_with_inheritance(config_file.attributes, 'OTHER_CPLUSPLUSFLAGS', react_native_debug_flag);
708+
self.add_flag_to_map_with_inheritance(config_file.attributes, 'OTHER_CFLAGS', react_native_debug_flag);
709+
710+
xcconfig_path = aggregate_target.xcconfig_path(config_name)
711+
config_file.save_as(xcconfig_path)
712+
end
713+
end
714+
715+
installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
716+
target_installation_result.native_target.build_configurations.each do |config|
717+
is_debug = config.type == :debug
718+
unless is_debug
719+
next
720+
end
721+
self.add_flag_to_map_with_inheritance(config.build_settings, 'OTHER_CPLUSPLUSFLAGS', react_native_debug_flag);
722+
self.add_flag_to_map_with_inheritance(config.build_settings, 'OTHER_CFLAGS', react_native_debug_flag);
687723
end
688724
end
689725
end

packages/react-native/scripts/react_native_pods.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ def react_native_post_install(
522522
ReactNativePodsUtils.updateOSDeploymentTarget(installer)
523523
ReactNativePodsUtils.set_dynamic_frameworks_flags(installer)
524524
ReactNativePodsUtils.add_ndebug_flag_to_pods_in_release(installer)
525+
ReactNativePodsUtils.add_react_native_debug_flag_to_pods_in_debug(installer)
525526

526527
if !ReactNativeCoreUtils.build_rncore_from_source()
527528
# In XCode 26 we need to revert the new setting SWIFT_ENABLE_EXPLICIT_MODULES when building

packages/rn-tester/Podfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,25 @@ end
7171

7272
post_install do |installer|
7373
react_native_post_install(installer, @prefix_path, :mac_catalyst_enabled => false)
74+
75+
installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
76+
# fix JSI symbol visibility for dynamic frameworks
77+
if (pod_name.include?('React') || pod_name.include?('MyNativeView')) && ENV['USE_FRAMEWORKS'] == 'dynamic'
78+
target_installation_result.native_target.build_configurations.each do |config|
79+
# ensure symbols are properly exported for dynamic frameworks
80+
config.build_settings['GCC_SYMBOLS_PRIVATE_EXTERN'] = 'NO'
81+
config.build_settings['DEFINES_MODULE'] = 'YES'
82+
83+
# add JSI framework search path for release builds
84+
if config.type == :release
85+
framework_search_paths = config.build_settings['FRAMEWORK_SEARCH_PATHS'] || '$(inherited)'
86+
if framework_search_paths.is_a?(String)
87+
config.build_settings['FRAMEWORK_SEARCH_PATHS'] = "#{framework_search_paths} \"${PODS_CONFIGURATION_BUILD_DIR}/React-jsi\""
88+
elsif framework_search_paths.is_a?(Array)
89+
config.build_settings['FRAMEWORK_SEARCH_PATHS'] = framework_search_paths + ["\"${PODS_CONFIGURATION_BUILD_DIR}/React-jsi\""]
90+
end
91+
end
92+
end
93+
end
94+
end
7495
end

0 commit comments

Comments
 (0)