Skip to content

Commit 967de03

Browse files
kelsetfacebook-github-bot
authored andcommitted
fix(ios): add xcode 14 workaround (turn off signing resource bundles) for pods (#34826)
Summary: This is inspired by the Expo workaround expo/expo@d970a9e to address an issue that cocoapods has with Xcode 14: CocoaPods/CocoaPods#11402 This wants to address this #34673 in a way that we can also cherry-pick on the 0.70 branch. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [iOS] [Fixed] - add xcode 14 workaround (turn off signing resource bundles) for `React-Core` Pull Request resolved: #34826 Test Plan: Tested locally by opening RNTester via Xcode 14.0.1, and targetting my iPhone as device. After applying the patch, the error for React Core AccessibilityResources disappears. Also, added ruby test for new patch. Reviewed By: hramos Differential Revision: D40063828 Pulled By: hramos fbshipit-source-id: e10d5b6a917a6a7cbacd14ecfdac55e60e46c6f8
1 parent 73bcedb commit 967de03

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

scripts/cocoapods/__tests__/utils-test.rb

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,62 @@ def test_fixReactBridgingHeaderSearchPaths_correctlySetsTheHeaderSearchPathsForA
382382
end
383383
end
384384

385+
# ===================================== #
386+
# Test - Apply Xcode14 React-Core patch #
387+
# ===================================== #
388+
389+
def test_turnOffResourceBundleReactCore_correctlyAppliesPatch
390+
# Arrange
391+
react_core_target = TargetMock.new('React-Core')
392+
react_core_target_native_target = react_core_target
393+
react_core_debug_config = prepare_Code_Signing_build_configuration("Debug", "YES")
394+
react_core_release_config = prepare_Code_Signing_build_configuration("Release", "YES")
395+
396+
hermes_engine_target = TargetMock.new('hermes-engine')
397+
hermes_engine_target_native_target = hermes_engine_target
398+
hermes_engine_debug_config = prepare_Code_Signing_build_configuration("Debug", "NO")
399+
hermes_engine_release_config = prepare_Code_Signing_build_configuration("Release", "NO")
400+
401+
assets_target = TargetMock.new('assets')
402+
assets_target_native_target = assets_target
403+
assets_debug_config = prepare_Code_Signing_build_configuration("Debug", "YES")
404+
assets_release_config = prepare_Code_Signing_build_configuration("Release", "YES")
405+
406+
installer = InstallerMock.new(pod_target_installation_results: {
407+
'React-Core':
408+
TargetInstallationResultMock.new(
409+
react_core_target,
410+
react_core_target_native_target,
411+
[TargetMock.new('React-Core',[react_core_debug_config, react_core_release_config])]
412+
),
413+
'hermes-engine':
414+
TargetInstallationResultMock.new(
415+
hermes_engine_target,
416+
hermes_engine_target_native_target,
417+
[TargetMock.new('hermes-engine',[hermes_engine_debug_config, hermes_engine_release_config])]
418+
),
419+
'assets':
420+
TargetInstallationResultMock.new(
421+
assets_target,
422+
assets_target_native_target,
423+
[TargetMock.new('assets',[assets_debug_config, assets_release_config])]
424+
),
425+
})
426+
427+
# Act
428+
ReactNativePodsUtils.turn_off_resource_bundle_react_core(installer)
429+
430+
# Assert
431+
# these must have changed
432+
assert_equal(react_core_debug_config.build_settings["CODE_SIGNING_ALLOWED"], "NO")
433+
assert_equal(react_core_release_config.build_settings["CODE_SIGNING_ALLOWED"], "NO")
434+
# these needs to stay the same
435+
assert_equal(hermes_engine_debug_config.build_settings["CODE_SIGNING_ALLOWED"], "NO")
436+
assert_equal(hermes_engine_release_config.build_settings["CODE_SIGNING_ALLOWED"], "NO")
437+
assert_equal(assets_debug_config.build_settings["CODE_SIGNING_ALLOWED"], "YES")
438+
assert_equal(assets_release_config.build_settings["CODE_SIGNING_ALLOWED"], "YES")
439+
end
440+
385441
# ================================= #
386442
# Test - Apply Mac Catalyst Patches #
387443
# ================================= #
@@ -502,3 +558,9 @@ def prepare_target(name, product_type = nil)
502558
prepare_config("Release")
503559
], product_type)
504560
end
561+
562+
def prepare_Code_Signing_build_configuration(name, param)
563+
return BuildConfigurationMock.new(name, {
564+
"CODE_SIGNING_ALLOWED" => param
565+
})
566+
end

scripts/cocoapods/utils.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ def self.has_pod(installer, name)
3939
installer.pods_project.pod_group(name) != nil
4040
end
4141

42+
def self.turn_off_resource_bundle_react_core(installer)
43+
# this is needed for Xcode 14, see more details here https://github.com/facebook/react-native/issues/34673
44+
# we should be able to remove this once CocoaPods catches up to it, see more details here https://github.com/CocoaPods/CocoaPods/issues/11402
45+
installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
46+
if pod_name.to_s == 'React-Core'
47+
target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
48+
resource_bundle_target.build_configurations.each do |config|
49+
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
50+
end
51+
end
52+
end
53+
end
54+
end
55+
4256
def self.exclude_i386_architecture_while_using_hermes(installer)
4357
projects = installer.aggregate_targets
4458
.map{ |t| t.user_project }

scripts/react_native_pods.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ def use_flipper!(versions = {}, configurations: ['Debug'])
188188
# - react_native_path: path to React Native.
189189
# - mac_catalyst_enabled: whether we are running the Pod on a Mac Catalyst project or not.
190190
def react_native_post_install(installer, react_native_path = "../node_modules/react-native", mac_catalyst_enabled: false)
191+
ReactNativePodsUtils.turn_off_resource_bundle_react_core(installer)
192+
191193
ReactNativePodsUtils.apply_mac_catalyst_patches(installer) if mac_catalyst_enabled
192194

193195
if ReactNativePodsUtils.has_pod(installer, 'Flipper')

0 commit comments

Comments
 (0)