Skip to content

Commit

Permalink
fix(ios): add xcode 14 workaround (turn off signing resource bundles)…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
kelset authored and facebook-github-bot committed Oct 7, 2022
1 parent 73bcedb commit 967de03
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
62 changes: 62 additions & 0 deletions scripts/cocoapods/__tests__/utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,62 @@ def test_fixReactBridgingHeaderSearchPaths_correctlySetsTheHeaderSearchPathsForA
end
end

# ===================================== #
# Test - Apply Xcode14 React-Core patch #
# ===================================== #

def test_turnOffResourceBundleReactCore_correctlyAppliesPatch
# Arrange
react_core_target = TargetMock.new('React-Core')
react_core_target_native_target = react_core_target
react_core_debug_config = prepare_Code_Signing_build_configuration("Debug", "YES")
react_core_release_config = prepare_Code_Signing_build_configuration("Release", "YES")

hermes_engine_target = TargetMock.new('hermes-engine')
hermes_engine_target_native_target = hermes_engine_target
hermes_engine_debug_config = prepare_Code_Signing_build_configuration("Debug", "NO")
hermes_engine_release_config = prepare_Code_Signing_build_configuration("Release", "NO")

assets_target = TargetMock.new('assets')
assets_target_native_target = assets_target
assets_debug_config = prepare_Code_Signing_build_configuration("Debug", "YES")
assets_release_config = prepare_Code_Signing_build_configuration("Release", "YES")

installer = InstallerMock.new(pod_target_installation_results: {
'React-Core':
TargetInstallationResultMock.new(
react_core_target,
react_core_target_native_target,
[TargetMock.new('React-Core',[react_core_debug_config, react_core_release_config])]
),
'hermes-engine':
TargetInstallationResultMock.new(
hermes_engine_target,
hermes_engine_target_native_target,
[TargetMock.new('hermes-engine',[hermes_engine_debug_config, hermes_engine_release_config])]
),
'assets':
TargetInstallationResultMock.new(
assets_target,
assets_target_native_target,
[TargetMock.new('assets',[assets_debug_config, assets_release_config])]
),
})

# Act
ReactNativePodsUtils.turn_off_resource_bundle_react_core(installer)

# Assert
# these must have changed
assert_equal(react_core_debug_config.build_settings["CODE_SIGNING_ALLOWED"], "NO")
assert_equal(react_core_release_config.build_settings["CODE_SIGNING_ALLOWED"], "NO")
# these needs to stay the same
assert_equal(hermes_engine_debug_config.build_settings["CODE_SIGNING_ALLOWED"], "NO")
assert_equal(hermes_engine_release_config.build_settings["CODE_SIGNING_ALLOWED"], "NO")
assert_equal(assets_debug_config.build_settings["CODE_SIGNING_ALLOWED"], "YES")
assert_equal(assets_release_config.build_settings["CODE_SIGNING_ALLOWED"], "YES")
end

# ================================= #
# Test - Apply Mac Catalyst Patches #
# ================================= #
Expand Down Expand Up @@ -502,3 +558,9 @@ def prepare_target(name, product_type = nil)
prepare_config("Release")
], product_type)
end

def prepare_Code_Signing_build_configuration(name, param)
return BuildConfigurationMock.new(name, {
"CODE_SIGNING_ALLOWED" => param
})
end
14 changes: 14 additions & 0 deletions scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ def self.has_pod(installer, name)
installer.pods_project.pod_group(name) != nil
end

def self.turn_off_resource_bundle_react_core(installer)
# this is needed for Xcode 14, see more details here https://github.com/facebook/react-native/issues/34673
# we should be able to remove this once CocoaPods catches up to it, see more details here https://github.com/CocoaPods/CocoaPods/issues/11402
installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
if pod_name.to_s == 'React-Core'
target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
resource_bundle_target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
end
end
end
end
end

def self.exclude_i386_architecture_while_using_hermes(installer)
projects = installer.aggregate_targets
.map{ |t| t.user_project }
Expand Down
2 changes: 2 additions & 0 deletions scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ def use_flipper!(versions = {}, configurations: ['Debug'])
# - react_native_path: path to React Native.
# - mac_catalyst_enabled: whether we are running the Pod on a Mac Catalyst project or not.
def react_native_post_install(installer, react_native_path = "../node_modules/react-native", mac_catalyst_enabled: false)
ReactNativePodsUtils.turn_off_resource_bundle_react_core(installer)

ReactNativePodsUtils.apply_mac_catalyst_patches(installer) if mac_catalyst_enabled

if ReactNativePodsUtils.has_pod(installer, 'Flipper')
Expand Down

0 comments on commit 967de03

Please sign in to comment.