Skip to content

Commit 8d288a9

Browse files
authored
fix(apple): workaround for code signing resource bundles (#1121)
1 parent 47547d9 commit 8d288a9

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

.rubocop.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Metrics/MethodLength:
2121
Enabled: false
2222

2323
Metrics/CyclomaticComplexity:
24-
IgnoredMethods: [make_project!, react_native_pods, use_test_app_internal!]
24+
AllowedMethods: [make_project!, react_native_pods, use_test_app_internal!]
2525

2626
Metrics/PerceivedComplexity:
27-
IgnoredMethods: [make_project!, react_native_pods, use_test_app_internal!]
27+
AllowedMethods: [make_project!, react_native_pods, use_test_app_internal!]
2828

2929
Naming/FileName:
3030
Exclude:

ios/test_app.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def react_native_path(project_root, target_platform)
7474
Pathname.new(resolve_module(react_native))
7575
end
7676

77+
def target_product_type(target)
78+
target.product_type if target.respond_to?(:product_type)
79+
end
80+
7781
def generate_assets_catalog!(project_root, target_platform, destination)
7882
xcassets_src = project_path('ReactTestApp/Assets.xcassets', target_platform)
7983
xcassets_dst = File.join(destination, File.basename(xcassets_src))
@@ -367,6 +371,8 @@ def make_project!(xcodeproj, project_root, target_platform, options)
367371
},
368372
:use_fabric => use_fabric,
369373
:use_turbomodule => use_turbomodule,
374+
:code_sign_identity => code_sign_identity || '',
375+
:development_team => development_team || '',
370376
}
371377
end
372378

@@ -449,6 +455,18 @@ def use_test_app_internal!(target_platform, options)
449455
end
450456
end
451457
end
458+
459+
next unless target_product_type(target) == 'com.apple.product-type.bundle'
460+
461+
# Code signing of resource bundles was enabled in Xcode 14. Not sure if
462+
# this is intentional, or if there's a bug in CocoaPods, but Xcode will
463+
# fail to build when targeting devices. Until this is resolved, we'll just
464+
# just have to make sure it's consistent with what's set in `app.json`.
465+
# See also https://github.com/CocoaPods/CocoaPods/issues/11402.
466+
target.build_configurations.each do |config|
467+
config.build_settings['CODE_SIGN_IDENTITY'] ||= project_target[:code_sign_identity]
468+
config.build_settings['DEVELOPMENT_TEAM'] ||= project_target[:development_team]
469+
end
452470
end
453471

454472
Pod::UI.notice(

0 commit comments

Comments
 (0)