Fix Fabric issue with React-Core pod when Xcode project has multiple targets (#37581)

Summary:
In Xcode projects with multiple targets, and in particular when targets are for different platforms (e.g. iOS and macOS), Cocoapods may add a suffix to a Pod name like `React-Core`.

When this happens, the code in `new_architecture.rb` (which was looking for a pod with exact name `React-Core`) would not add the preprocessor definitions for Fabric as expected.

This change fixes this issue. Fixes https://github.com/facebook/react-native/issues/37102 .

## Changelog:

[iOS] [Fixed] - Fix Fabric issue with React-Core pod when Xcode project has multiple targets

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

Test Plan: Tested that this change fixes this issue which occurs 100% of the time in React Native TV projects.

Reviewed By: dmytrorykun

Differential Revision: D46264704

Pulled By: cipolleschi

fbshipit-source-id: 8dfc8e342b5a110ef1f028636e01e5c5f2b6e2f0
This commit is contained in:
Douglas Lowder 2023-05-30 06:44:49 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 5eadd935e8
Коммит d3e35992e9
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -16,7 +16,8 @@ class NewArchitectureHelper
language_standard = nil
installer.pods_project.targets.each do |target|
if target.name == 'React-Core'
# The React-Core pod may have a suffix added by Cocoapods, so we test whether 'React-Core' is a substring, and do not require exact match
if target.name.include? 'React-Core'
language_standard = target.resolved_build_setting("CLANG_CXX_LANGUAGE_STANDARD", resolve_against_xcconfig: true).values[0]
end
end
@ -61,7 +62,8 @@ class NewArchitectureHelper
# Add RCT_NEW_ARCH_ENABLED to generated pod target projects
installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
if pod_name == 'React-Core'
# The React-Core pod may have a suffix added by Cocoapods, so we test whether 'React-Core' is a substring, and do not require exact match
if pod_name.include? 'React-Core'
target_installation_result.native_target.build_configurations.each do |config|
config.build_settings['OTHER_CPLUSPLUSFLAGS'] = @@new_arch_cpp_flags
end