diff --git a/CHANGELOG.md b/CHANGELOG.md index a62e3774ad..492f02b84a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` [Igor Makarov](https://github.com/igor-makarov) [#9431](https://github.com/CocoaPods/CocoaPods/pull/9431) +* Fix an issue that caused an incorrect warning to be emitted for CLI targets with static libraries + [Eric Amorde](https://github.com/amorde) + [#9498](https://github.com/CocoaPods/CocoaPods/issues/9498) + ## 1.9.0.beta.2 (2019-12-17) ##### Enhancements diff --git a/lib/cocoapods/installer/analyzer.rb b/lib/cocoapods/installer/analyzer.rb index 54ae3cb0c2..dd4c7e0a53 100644 --- a/lib/cocoapods/installer/analyzer.rb +++ b/lib/cocoapods/installer/analyzer.rb @@ -334,15 +334,16 @@ def embedded_target_pod_targets_by_host(aggregate_target, embedded_aggregate_tar # def analyze_host_targets_in_podfile(aggregate_targets, embedded_aggregate_targets) target_definitions_by_uuid = {} - cli_host_with_frameworks = [] + cli_host_with_dynamic_linkage = [] cli_product_type = 'com.apple.product-type.tool' # Collect aggregate target definitions by uuid to later lookup host target # definitions and verify their compatibility with their embedded targets aggregate_targets.each do |target| target.user_targets.each do |user_target| - target_definitions_by_uuid[user_target.uuid] = target.target_definition - if user_target.product_type == cli_product_type - cli_host_with_frameworks << user_target + target_definition = target.target_definition + target_definitions_by_uuid[user_target.uuid] = target_definition + if user_target.product_type == cli_product_type && target_definition.build_type.linkage == :dynamic + cli_host_with_dynamic_linkage << user_target end end end @@ -368,10 +369,10 @@ def analyze_host_targets_in_podfile(aggregate_targets, embedded_aggregate_target end end - unless cli_host_with_frameworks.empty? - UI.warn "The Podfile contains command line tool target(s) (#{cli_host_with_frameworks.map(&:name).to_sentence}) which are attempting to integrate dynamic frameworks." \ + unless cli_host_with_dynamic_linkage.empty? + UI.warn "The Podfile contains command line tool target(s) (#{cli_host_with_dynamic_linkage.map(&:name).to_sentence}) which are attempting to integrate dynamic frameworks or libraries." \ "\n" \ - 'This may not behave as expected, because command line tools are usually distributed as a single binary and cannot contain their own dynamic frameworks.' + 'This may not behave as expected, because command line tools are usually distributed as a single binary and cannot contain their own dynamic dependencies.' end unless embedded_targets_missing_hosts.empty? diff --git a/spec/unit/installer/analyzer_spec.rb b/spec/unit/installer/analyzer_spec.rb index ecaadde312..d29c6dabd1 100644 --- a/spec/unit/installer/analyzer_spec.rb +++ b/spec/unit/installer/analyzer_spec.rb @@ -2006,7 +2006,22 @@ module Pod end analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile) analyzer.analyze - UI.warnings.should.match /The Podfile contains command line tool target\(s\) \(SampleCommandLineTool\) which are attempting to integrate dynamic frameworks\./ + UI.warnings.should.match /The Podfile contains command line tool target\(s\) \(SampleCommandLineTool\) which are attempting to integrate dynamic frameworks or libraries\./ + end + + it 'does not warn when using static libraries with CLI targets' do + project_path = fixture('Sample Extensions Project/Sample Extensions Project') + podfile = Pod::Podfile.new do + source SpecHelper.test_repo_url + platform :ios, '8.0' + project project_path + target 'SampleCommandLineTool' do + pod 'monkey' + end + end + analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile) + analyzer.analyze + UI.warnings.should.be.empty? end it 'raises when the extension calls use_frameworks!, but the host target does not' do