From 6128c4c4c07c2cdc907309dbd90385409922b7fd Mon Sep 17 00:00:00 2001 From: Dimitris Koutsogiorgas Date: Fri, 18 Jan 2019 12:02:34 -0800 Subject: [PATCH] Do not generate default `Info.plist` file for test targets if one is already specified. --- CHANGELOG.md | 4 +++ .../pod_target_installer.rb | 25 +++++++++++++------ .../target_installer.rb | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8c304f49c..3c29ab524b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ##### Bug Fixes +* Do not generate default `Info.plist` file for test targets if one is already specified. + [Dimitris Koutsogiorgas](https://github.com/dnkoutso) + [#8432](https://github.com/CocoaPods/CocoaPods/pull/8432) + * Set `showEnvVarsInLog` for script phases only when its disabled. [Dimitris Koutsogiorgas](https://github.com/dnkoutso) [#8400](https://github.com/CocoaPods/CocoaPods/pull/8400) diff --git a/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb b/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb index 54fb002150..80e62581aa 100644 --- a/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +++ b/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb @@ -97,10 +97,22 @@ def install! add_swift_library_compatibility_header_phase(native_target) end + target.test_spec_consumers.each do |test_spec_consumer| + test_native_target = test_native_target_from_spec_consumer(test_spec_consumer, test_native_targets) + unless skip_info_plist?(test_native_target) + # Generate vanilla Info.plist for test target similar to the one Xcode generates for new test target. + # This creates valid test bundle accessible at the runtime, allowing tests to load bundle resources + # defined in podspec. + create_info_plist_file(target.info_plist_path_for_spec(test_spec_consumer.spec), test_native_target, + '1.0', target.platform, :bndl) + end + end + unless skip_pch?(target.library_specs) path = target.prefix_header_path create_prefix_header(path, library_file_accessors, target.platform, native_target) end + unless skip_pch?(target.test_specs) target.test_specs.each do |test_spec| path = target.prefix_header_path_for_spec(test_spec) @@ -109,6 +121,7 @@ def install! create_prefix_header(path, test_file_accessors, target.platform, test_native_target) end end + unless skip_pch?(target.app_specs) target.app_specs.each do |app_spec| path = target.prefix_header_path_for_spec(app_spec) @@ -136,11 +149,14 @@ def skip_pch?(specs) specs.any? { |spec| spec.prefix_header_file.is_a?(FalseClass) } end - # True if info.plist generation should be skipped + # True if default Info.plist generation should be skipped # # @param [PXNativeTarget] native_target + # The native target to check whether it already has `INFOPLIST_FILE` set. # - # @return [Boolean] Whether the target should build an Info.plist file + # @return [Boolean] + # Whether the target should skip generating a default Info.plist file because one is already specified + # in the target build settings. # def skip_info_plist?(native_target) existing_setting = native_target.resolved_build_setting('INFOPLIST_FILE', true).values.compact @@ -326,11 +342,6 @@ def add_test_targets create_test_target_embed_frameworks_script(test_spec) create_test_target_copy_resources_script(test_spec) - # Generate vanilla Info.plist for test target similar to the one Xcode generates for new test target. - # This creates valid test bundle accessible at the runtime, allowing tests to load bundle resources - # defined in podspec. - create_info_plist_file(target.info_plist_path_for_spec(test_spec), test_native_target, '1.0', target.platform, :bndl) - test_native_target end end diff --git a/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb b/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb index c9742f84eb..5f0d7624a1 100644 --- a/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +++ b/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb @@ -138,7 +138,7 @@ def support_files_temp_dir # @return [void] # def create_info_plist_file(path, native_target, version, platform, bundle_package_type = :fmwk) - create_info_plist_file_with_sandbox(@sandbox, path, native_target, version, platform, bundle_package_type) + create_info_plist_file_with_sandbox(sandbox, path, native_target, version, platform, bundle_package_type) add_file_to_support_group(path) end