[Resolver] Handle when an abstract target has no platform

parent 5c2ef75f
...@@ -577,7 +577,8 @@ module Pod ...@@ -577,7 +577,8 @@ module Pod
def validate_platforms(specs_by_target) def validate_platforms(specs_by_target)
specs_by_target.each do |target, specs| specs_by_target.each do |target, specs|
specs.each do |spec| specs.each do |spec|
unless spec.available_platforms.any? { |p| target.platform.supports?(p) } next unless target_platform = target.platform
unless spec.available_platforms.any? { |p| target_platform.supports?(p) }
UI.warn "The platform of the target `#{target.name}` " \ UI.warn "The platform of the target `#{target.name}` " \
"(#{target.platform}) may not be compatible with `#{spec}` which has " \ "(#{target.platform}) may not be compatible with `#{spec}` which has " \
"a minimum requirement of #{spec.available_platforms.join(' - ')}." "a minimum requirement of #{spec.available_platforms.join(' - ')}."
......
...@@ -56,7 +56,7 @@ module Pod ...@@ -56,7 +56,7 @@ module Pod
def resolve def resolve
dependencies = podfile.target_definition_list.flat_map do |target| dependencies = podfile.target_definition_list.flat_map do |target|
target.dependencies.each do |dep| target.dependencies.each do |dep|
@platforms_by_dependency[dep].push(target.platform).uniq! @platforms_by_dependency[dep].push(target.platform).uniq! if target.platform
end end
end end
@activated = Molinillo::Resolver.new(self, self).resolve(dependencies, locked_dependencies) @activated = Molinillo::Resolver.new(self, self).resolve(dependencies, locked_dependencies)
...@@ -363,7 +363,8 @@ module Pod ...@@ -363,7 +363,8 @@ module Pod
# @return [void] # @return [void]
# #
def validate_platform(spec, target) def validate_platform(spec, target)
unless spec.available_platforms.any? { |p| target.platform.to_sym == p.to_sym } return unless target_platform = target.platform
unless spec.available_platforms.any? { |p| target_platform.to_sym == p.to_sym }
raise Informative, "The platform of the target `#{target.name}` " \ raise Informative, "The platform of the target `#{target.name}` " \
"(#{target.platform}) is not compatible with `#{spec}`, which does " \ "(#{target.platform}) is not compatible with `#{spec}`, which does " \
"not support `#{target.platform.name}`." "not support `#{target.platform.name}`."
...@@ -418,7 +419,7 @@ module Pod ...@@ -418,7 +419,7 @@ module Pod
end end
message << "\nYou should explicitly specify the version in order to install a pre-release version" message << "\nYou should explicitly specify the version in order to install a pre-release version"
elsif !conflict.existing elsif !conflict.existing
conflict.requirements.values.flatten.each do |r| conflict.requirements.values.flatten.uniq.each do |r|
if search_for(r).empty? if search_for(r).empty?
# There are no existing specification inside any of the spec repos with given requirements. # There are no existing specification inside any of the spec repos with given requirements.
message << "\n\nNone of your spec sources contain a spec satisfying the dependency: `#{r}`." \ message << "\n\nNone of your spec sources contain a spec satisfying the dependency: `#{r}`." \
......
...@@ -163,6 +163,33 @@ module Pod ...@@ -163,6 +163,33 @@ module Pod
target.platform.to_s.should == 'iOS 6.0' target.platform.to_s.should == 'iOS 6.0'
end end
describe 'abstract targets' do
it 'resolves' do
@podfile = Pod::Podfile.new do
project 'SampleProject/SampleProject'
use_frameworks!
abstract_target 'Alpha' do
pod 'libextobjc'
target 'SampleProject' do
pod 'libextobjc/RuntimeExtensions'
end
target 'TestRunner' do
end
end
end
@analyzer = Pod::Installer::Analyzer.new(config.sandbox, @podfile, nil)
result = @analyzer.analyze
sample_project_target, test_runner_target = result.targets.sort_by(&:name)
sample_project_target.pod_targets.map(&:name).should == %w(libextobjc)
test_runner_target.pod_targets.map(&:name).should.be.empty
sample_project_target.user_targets.map(&:name).should == %w(SampleProject)
test_runner_target.user_targets.map(&:name).should == %w(TestRunner)
end
end
describe 'dependent pod targets' do describe 'dependent pod targets' do
it 'picks transitive dependencies up' do it 'picks transitive dependencies up' do
@podfile = Pod::Podfile.new do @podfile = Pod::Podfile.new do
......
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