Unverified Commit 1828d95c authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7373 from paulb777/sf-transitive-error

Better static frameworks transitive dependency error checking
parents dd25038c f97c56da
...@@ -25,6 +25,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -25,6 +25,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes ##### Bug Fixes
* Better static frameworks transitive dependency error checking
[Paul Beusterien](https://github.com/paulb777)
[#7352](https://github.com/CocoaPods/CocoaPods/issues/7352)
* Always update input/output paths even if they are empty * Always update input/output paths even if they are empty
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7368](https://github.com/CocoaPods/CocoaPods/pull/7368) [#7368](https://github.com/CocoaPods/CocoaPods/pull/7368)
......
...@@ -71,16 +71,22 @@ module Pod ...@@ -71,16 +71,22 @@ module Pod
next unless aggregate_target.requires_frameworks? next unless aggregate_target.requires_frameworks?
aggregate_target.user_build_configurations.keys.each do |config| aggregate_target.user_build_configurations.keys.each do |config|
pod_targets = aggregate_target.pod_targets_for_build_configuration(config) dynamic_pod_targets = aggregate_target.pod_targets_for_build_configuration(config).reject(&:static_framework?)
dependencies = pod_targets.select(&:should_build?).reject(&:static_framework?).flat_map(&:dependencies) dependencies = dynamic_pod_targets.select(&:should_build?).flat_map(&:dependencies)
depended_upon_targets = pod_targets.select { |t| dependencies.include?(t.pod_name) && !t.should_build? } depended_upon_targets = dynamic_pod_targets.select { |t| dependencies.include?(t.pod_name) && !t.should_build? }
static_libs = depended_upon_targets.flat_map(&:file_accessors).flat_map(&:vendored_static_artifacts) static_libs = depended_upon_targets.flat_map(&:file_accessors).flat_map(&:vendored_static_artifacts)
unless static_libs.empty? unless static_libs.empty?
raise Informative, "The '#{aggregate_target.label}' target has " \ raise Informative, "The '#{aggregate_target.label}' target has " \
"transitive dependencies that include static binaries: (#{static_libs.to_sentence})" "transitive dependencies that include static binaries: (#{static_libs.to_sentence})"
end end
static_framework_deps = dynamic_pod_targets.select(&:should_build?).flat_map(&:recursive_dependent_targets).select(&:static_framework?)
unless static_framework_deps.empty?
raise Informative, "The '#{aggregate_target.label}' target has " \
"transitive dependencies that include static frameworks: (#{static_framework_deps.flat_map(&:name).to_sentence})"
end
end end
end end
end end
......
...@@ -7,7 +7,6 @@ Pod::Spec.new do |s| ...@@ -7,7 +7,6 @@ Pod::Spec.new do |s|
s.homepage = "http://httpbin.org/html" s.homepage = "http://httpbin.org/html"
s.source = { :git => "http://malyutin.local/matryoshka.git", :tag => s.version.to_s } s.source = { :git => "http://malyutin.local/matryoshka.git", :tag => s.version.to_s }
s.license = 'MIT' s.license = 'MIT'
s.static_framework = true
s.source_files = 'Outmost.{h,m}' s.source_files = 'Outmost.{h,m}'
......
Pod::Spec.new do |s|
s.name = "matryoshka"
s.version = "1.0.0"
s.author = { "Matryona Malyutin" => "matryona@malyutin.local" }
s.summary = "👩‍👩‍👧"
s.description = "Four levels: outmost (root), outer, inner"
s.homepage = "http://httpbin.org/html"
s.source = { :git => "http://malyutin.local/matryoshka.git", :tag => s.version.to_s }
s.license = 'MIT'
s.static_framework = true
s.source_files = 'Outmost.{h,m}'
s.dependency 'monkey'
end
...@@ -172,6 +172,57 @@ module Pod ...@@ -172,6 +172,57 @@ module Pod
@validator = create_validator(config.sandbox, @podfile, @lockfile) @validator = create_validator(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @validator.validate! } should.not.raise(Informative) { @validator.validate! }
end end
end
describe '#verify_no_incorrect_static_framework_transitive_dependencies_with_static_frameworks' do
before do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
@podfile = Pod::Podfile.new do
install! 'cocoapods', 'integrate_targets' => false
platform :ios, '8.0'
project 'SampleProject/SampleProject'
use_frameworks!
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
pod 'CoconutLib', :path => (fixture_path + 'coconut-lib').to_s
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'matryoshka', :path => (fixture_path + 'static-matryoshka').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s
target 'SampleProject'
end
@lockfile = generate_lockfile
@file = Pathname('/yolo.m')
@file.stubs(:realpath).returns(@file)
@lib_thing = Pathname('/libThing.a')
@lib_thing.stubs(:realpath).returns(@lib_thing)
end
it 'detects transitive static dependencies which are linked directly to the user target' do
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*monkey.a/
end
it 'detects transitive static dependencies which are linked directly to the user target with stubbing' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*libThing/
end
it 'detects transitive static dependencies to static frameworks from dynamic library pods' do
Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([@file])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*matryoshka/
end
it 'allows transitive static dependencies when both dependencies are linked against the user target' do
PodTarget.any_instance.stubs(:should_build? => false)
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @validator.validate! }
end
it 'allows transitive static dependencies when building a static framework' do it 'allows transitive static dependencies when building a static framework' do
PodTarget.any_instance.stubs(:static_framework? => true) PodTarget.any_instance.stubs(:static_framework? => true)
...@@ -190,7 +241,7 @@ module Pod ...@@ -190,7 +241,7 @@ module Pod
platform :ios, '8.0' platform :ios, '8.0'
project 'SampleProject/SampleProject' project 'SampleProject/SampleProject'
use_frameworks! use_frameworks!
pod 'matryoshka/Bar', :path => (fixture_path + 'matryoshka').to_s pod 'matryoshka', :path => (fixture_path + 'static-matryoshka').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s pod 'monkey', :path => (fixture_path + 'monkey').to_s
target 'SampleProject' target 'SampleProject'
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment