Commit 70487ea7 authored by Samuel Giddins's avatar Samuel Giddins Committed by GitHub

Merge pull request #5505 from DanToml/dan_4014

[Installer] Verify no duplicate static libs
parents c5d3cc85 6246b387
......@@ -12,7 +12,7 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Daniel Tomlinson](https://github.com/dantoml)
[#5480](https://github.com/CocoaPods/CocoaPods/pull/5480)
* Add the ability to inhibit swift warnings.
* Add the ability to inhibit swift warnings.
[Peter Ryszkiewicz](https://github.com/pRizz)
[#5414](https://github.com/CocoaPods/CocoaPods/pull/5414)
......@@ -74,6 +74,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Boris Bügling](https://github.com/neonichu)
[#5528](https://github.com/CocoaPods/CocoaPods/issues/5528)
* Error during install when there are duplicate library names.
[Daniel Tomlinson](https://github.com/dantoml)
[#4014](https://github.com/CocoaPods/CocoaPods/issues/4014)
## 1.0.1 (2016-06-02)
......
......@@ -110,7 +110,7 @@ module Pod
prepare
resolve_dependencies
download_dependencies
verify_no_duplicate_framework_names
verify_no_duplicate_framework_and_library_names
verify_no_static_framework_transitive_dependencies
verify_framework_usage
generate_pods_project
......@@ -389,23 +389,32 @@ module Pod
end
end
def verify_no_duplicate_framework_names
def verify_no_duplicate_framework_and_library_names
aggregate_targets.each do |aggregate_target|
aggregate_target.user_build_configurations.keys.each do |config|
pod_targets = aggregate_target.pod_targets_for_build_configuration(config)
vendored_frameworks = pod_targets.flat_map(&:file_accessors).flat_map(&:vendored_frameworks).uniq
frameworks = vendored_frameworks.map { |fw| fw.basename('.framework') }
file_accessors = pod_targets.flat_map(&:file_accessors)
frameworks = file_accessors.flat_map(&:vendored_frameworks).uniq.map(&:basename)
frameworks += pod_targets.select { |pt| pt.should_build? && pt.requires_frameworks? }.map(&:product_module_name)
verify_no_duplicate_names(frameworks, aggregate_target.label, 'frameworks')
duplicates = frameworks.group_by { |f| f }.select { |_, v| v.size > 1 }.keys
unless duplicates.empty?
raise Informative, "The '#{aggregate_target.label}' target has " \
"frameworks with conflicting names: #{duplicates.to_sentence}."
end
libraries = file_accessors.flat_map(&:vendored_libraries).uniq.map(&:basename)
libraries += pod_targets.select { |pt| pt.should_build? && !pt.requires_frameworks? }.map(&:product_name)
verify_no_duplicate_names(libraries, aggregate_target.label, 'libraries')
end
end
end
def verify_no_duplicate_names(names, label, type)
duplicates = names.map { |n| n.to_s.downcase }.group_by { |f| f }.select { |_, v| v.size > 1 }.keys
unless duplicates.empty?
raise Informative, "The '#{label}' target has " \
"#{type} with conflicting names: #{duplicates.to_sentence}."
end
end
def verify_no_static_framework_transitive_dependencies
aggregate_targets.each do |aggregate_target|
next unless aggregate_target.requires_frameworks?
......
......@@ -434,7 +434,7 @@ module Pod
# for all available platforms with xcodebuild.
#
def install_pod
%i(verify_no_duplicate_framework_names
%i(verify_no_duplicate_framework_and_library_names
verify_no_static_framework_transitive_dependencies
verify_framework_usage generate_pods_project integrate_user_project
perform_post_install_actions).each { |m| @installer.send(m) }
......
......@@ -61,7 +61,7 @@ module Pod
before do
@installer.stubs(:resolve_dependencies)
@installer.stubs(:download_dependencies)
@installer.stubs(:verify_no_duplicate_framework_names)
@installer.stubs(:verify_no_duplicate_framework_and_library_names)
@installer.stubs(:verify_no_static_framework_transitive_dependencies)
@installer.stubs(:verify_framework_usage)
@installer.stubs(:generate_pods_project)
......@@ -258,7 +258,25 @@ module Pod
#-------------------------------------------------------------------------#
describe '#verify_no_duplicate_framework_names' do
describe '#verify_no_duplicate_framework_and_library_names' do
it 'detects duplicate library names' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([Pathname('a/libBananalib.a')])
Pod::Specification.any_instance.stubs(:dependencies).returns([])
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Pod::Podfile.new do
platform :ios, '8.0'
project 'SampleProject/SampleProject'
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
target 'SampleProject'
end
lockfile = generate_lockfile
@installer = Installer.new(config.sandbox, podfile, lockfile)
@installer.installation_options.integrate_targets = false
should.raise(Informative) { @installer.install! }.message.should.match /conflict.*bananalib/
end
it 'detects duplicate framework names' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_frameworks).
returns([Pathname('a/monkey.framework')]).then.
......
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