diff --git a/CHANGELOG.md b/CHANGELOG.md index 21b24ae970..ebffe363fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ##### Bug Fixes -* None. +* Do not validate modular header dependencies for pre-built Swift pods. + [Dimitris Koutsogiorgas](https://github.com/dnkoutso) + [#10912](https://github.com/CocoaPods/CocoaPods/issues/10912) ## 1.11.0 (2021-09-01) diff --git a/lib/cocoapods/installer/xcode/target_validator.rb b/lib/cocoapods/installer/xcode/target_validator.rb index e0c214e1d4..738e3b7d08 100644 --- a/lib/cocoapods/installer/xcode/target_validator.rb +++ b/lib/cocoapods/installer/xcode/target_validator.rb @@ -129,7 +129,7 @@ def verify_swift_pods_swift_version def verify_swift_pods_have_module_dependencies error_messages = [] pod_targets.each do |pod_target| - next unless pod_target.uses_swift? + next unless pod_target.uses_swift? && pod_target.should_build? non_module_dependencies = [] pod_target.dependent_targets.each do |dependent_target| diff --git a/spec/unit/installer/xcode/target_validator_spec.rb b/spec/unit/installer/xcode/target_validator_spec.rb index 5f6007b548..6c3c5259b9 100644 --- a/spec/unit/installer/xcode/target_validator_spec.rb +++ b/spec/unit/installer/xcode/target_validator_spec.rb @@ -448,6 +448,7 @@ def create_validator(sandbox, podfile, lockfile) @validator = create_validator(config.sandbox, podfile, lockfile) @validator.stubs(:pod_targets).returns([stub('MultiSwift', :uses_swift? => true, + :should_build? => true, :swift_version => nil, :dependent_targets => [], :spec_swift_versions => ['4.0'])]) @@ -519,6 +520,29 @@ def create_validator(sandbox, podfile, lockfile) @validator.pod_targets.find { |pt| pt.name == 'matryoshka' }.stubs(:should_build?).returns(false) lambda { @validator.validate! }.should.not.raise end + + it 'does not raise when a pre built swift target depends upon a target that requires building' do + fixture_path = ROOT + 'spec/fixtures' + config.repos_dir = fixture_path + 'spec-repos' + podfile = Podfile.new do + project(fixture_path + 'SampleProject/SampleProject').to_s + platform :ios, '12.0' + install! 'cocoapods', :integrate_targets => false + pod 'VendoredSwiftFramework', :path => (fixture_path + 'prebuilt-swift-framework').to_s + pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s + target 'SampleProject' + target 'TestRunner' + end + lockfile = generate_lockfile + + @validator = create_validator(config.sandbox, podfile, lockfile) + podfile.target_definition_list.find { |td| td.name == 'SampleProject' }.swift_version = '3.0' + podfile.target_definition_list.find { |td| td.name == 'TestRunner' }.swift_version = '3.0' + vendored_swift_framework_pod_target = @validator.pod_targets.find { |pt| pt.name == 'VendoredSwiftFramework' } + matryoshka_pod_target = @validator.pod_targets.find { |pt| pt.name == 'matryoshka' } + vendored_swift_framework_pod_target.stubs(:dependent_targets).returns([matryoshka_pod_target]) + lambda { @validator.validate! }.should.not.raise + end end describe '#verify_no_multiple_project_names' do