Skip to content

Commit c5e549e

Browse files
author
Riccardo Cipolleschi
committed
[LOCAL] Make 0.70 compatible with Xcode 15 (thanks to @AlexanderEggers for the commit in main)
1 parent 51bbfe1 commit c5e549e

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

scripts/cocoapods/__tests__/utils-test.rb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,60 @@ def test_applyMacCatalystPatches_correctlyAppliesNecessaryPatches
474474
assert_equal(user_project_mock.save_invocation_count, 1)
475475
end
476476

477+
# ================================= #
478+
# Test - Apply Xcode 15 Patch #
479+
# ================================= #
480+
481+
def test_applyXcode15Patch_correctlyAppliesNecessaryPatch
482+
# Arrange
483+
first_target = prepare_target("FirstTarget")
484+
second_target = prepare_target("SecondTarget")
485+
third_target = TargetMock.new("ThirdTarget", [
486+
BuildConfigurationMock.new("Debug", {
487+
"GCC_PREPROCESSOR_DEFINITIONS" => '$(inherited) "SomeFlag=1" '
488+
}),
489+
BuildConfigurationMock.new("Release", {
490+
"GCC_PREPROCESSOR_DEFINITIONS" => '$(inherited) "SomeFlag=1" '
491+
}),
492+
], nil)
493+
494+
user_project_mock = UserProjectMock.new("a/path", [
495+
prepare_config("Debug"),
496+
prepare_config("Release"),
497+
],
498+
:native_targets => [
499+
first_target,
500+
second_target
501+
]
502+
)
503+
pods_projects_mock = PodsProjectMock.new([], {"hermes-engine" => {}}, :native_targets => [
504+
third_target
505+
])
506+
installer = InstallerMock.new(pods_projects_mock, [
507+
AggregatedProjectMock.new(user_project_mock)
508+
])
509+
510+
# Act
511+
ReactNativePodsUtils.apply_xcode_15_patch(installer)
512+
513+
# Assert
514+
first_target.build_configurations.each do |config|
515+
assert_equal(config.build_settings["GCC_PREPROCESSOR_DEFINITIONS"].strip,
516+
'$(inherited) "_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION"'
517+
)
518+
end
519+
second_target.build_configurations.each do |config|
520+
assert_equal(config.build_settings["GCC_PREPROCESSOR_DEFINITIONS"].strip,
521+
'$(inherited) "_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION"'
522+
)
523+
end
524+
third_target.build_configurations.each do |config|
525+
assert_equal(config.build_settings["GCC_PREPROCESSOR_DEFINITIONS"].strip,
526+
'$(inherited) "SomeFlag=1" "_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION"'
527+
)
528+
end
529+
end
530+
477531
# ==================================== #
478532
# Test - Set Node_Modules User Setting #
479533
# ==================================== #

scripts/cocoapods/utils.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ def self.fix_react_bridging_header_search_paths(installer)
119119
end
120120
end
121121

122+
def self.apply_xcode_15_patch(installer)
123+
installer.target_installation_results.pod_target_installation_results
124+
.each do |pod_name, target_installation_result|
125+
target_installation_result.native_target.build_configurations.each do |config|
126+
# unary_function and binary_function are no longer provided in C++17 and newer standard modes as part of Xcode 15. They can be re-enabled with setting _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
127+
# Ref: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Deprecations
128+
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= '$(inherited) '
129+
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << '"_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION" '
130+
end
131+
end
132+
end
133+
122134
def self.apply_mac_catalyst_patches(installer)
123135
# Fix bundle signing issues
124136
installer.pods_project.targets.each do |target|

scripts/react_native_pods.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re
162162
ReactNativePodsUtils.fix_library_search_paths(installer)
163163
ReactNativePodsUtils.fix_react_bridging_header_search_paths(installer)
164164
ReactNativePodsUtils.set_node_modules_user_settings(installer, react_native_path)
165+
ReactNativePodsUtils.apply_xcode_15_patch(installer)
165166

166167
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
167168
is_new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'

0 commit comments

Comments
 (0)