Commit 6b68f529 authored by Eloy Duran's avatar Eloy Duran

Don’t create a target if its definition, in the Podfile, is empty (no dependencies). Closes #79.

parent 0318141b
......@@ -18,7 +18,7 @@ module Pod
include Config::Mixin
include Shared
attr_reader :target
attr_reader :podfile, :project, :definition, :target
def initialize(podfile, project, definition)
@podfile, @project, @definition = podfile, project, definition
......@@ -163,8 +163,8 @@ module Pod
def target_installers
@target_installers ||= @podfile.target_definitions.values.map do |definition|
TargetInstaller.new(@podfile, project, definition)
end
TargetInstaller.new(@podfile, project, definition) unless definition.empty?
end.compact
end
def install!
......
......@@ -8,7 +8,13 @@ module Pod
end
def lib_name
name == :default ? "Pods" : "Pods-#{name}"
if name == :default
"Pods"
elsif @parent
"#{@parent.lib_name}-#{name}"
else
"Pods-#{name}"
end
end
# Returns *all* dependencies of this target, not only the target specific
......@@ -16,6 +22,10 @@ module Pod
def dependencies
@target_dependencies + (@parent ? @parent.dependencies : [])
end
def empty?
target_dependencies.empty?
end
end
def self.from_file(path)
......
......@@ -3,7 +3,10 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Installer" do
describe ", by default," do
before do
@xcconfig = Pod::Installer.new(Pod::Podfile.new { platform :ios }).target_installers.first.xcconfig.to_hash
@xcconfig = Pod::Installer.new(Pod::Podfile.new do
platform :ios
dependency 'JSONKit'
end).target_installers.first.xcconfig.to_hash
end
it "sets the header search paths where installed Pod headers can be found" do
......@@ -45,6 +48,17 @@ describe "Pod::Installer" do
installer.target_installers.first.bridge_support_generator.headers.should == expected
end
it "omits empty target definitions" do
podfile = Pod::Podfile.new do
platform :ios
target :not_empty do
dependency 'JSONKit'
end
end
installer = Pod::Installer.new(podfile)
installer.target_installers.map(&:definition).map(&:name).should == [:not_empty]
end
it "moves the compile and link phases to the end of the build phases list, so Pod headers are copied first and sources can use the same header dir structure" do
podfile = Pod::Podfile.new do
platform :osx
......
......@@ -60,6 +60,14 @@ describe "Pod::Podfile" do
end
describe "concerning targets (dependency groups)" do
it "returns wether or not a target has any dependencies" do
Pod::Podfile.new do
end.target_definitions[:default].should.be.empty
Pod::Podfile.new do
dependency 'JSONKit'
end.target_definitions[:default].should.not.be.empty
end
before do
@podfile = Pod::Podfile.new do
target :debug do
......@@ -68,6 +76,9 @@ describe "Pod::Podfile" do
target :test, :exclusive => true do
dependency 'JSONKit'
target :subtarget do
dependency 'Reachability'
end
end
dependency 'ASIHTTPRequest'
......@@ -75,7 +86,7 @@ describe "Pod::Podfile" do
end
it "returns all dependencies of all targets combined, which is used during resolving to enusre compatible dependencies" do
@podfile.dependencies.map(&:name).sort.should == %w{ ASIHTTPRequest JSONKit SSZipArchive }
@podfile.dependencies.map(&:name).sort.should == %w{ ASIHTTPRequest JSONKit Reachability SSZipArchive }
end
it "adds dependencies outside of any explicit target block to the default target" do
......@@ -98,6 +109,12 @@ describe "Pod::Podfile" do
target.lib_name.should == 'Pods-test'
target.dependencies.should == [Pod::Dependency.new('JSONKit')]
end
it "adds dependencies of the outer target to nested targets" do
target = @podfile.target_definitions[:subtarget]
target.lib_name.should == 'Pods-test-subtarget'
target.dependencies.should == [Pod::Dependency.new('Reachability'), Pod::Dependency.new('JSONKit')]
end
end
describe "concerning validations" 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