Commit b446d8c9 authored by Eloy Duran's avatar Eloy Duran

Add Podfile#link_with which takes a target (or an array of targets) to link the library with.

parent 07fad458
module Pod module Pod
class Podfile class Podfile
class TargetDefinition class TargetDefinition
attr_reader :name, :parent, :target_dependencies attr_reader :name, :target_dependencies
attr_accessor :link_with, :parent
def initialize(name, parent = nil) def initialize(name, options = {})
@name, @parent, @target_dependencies = name, parent, [] @name, @target_dependencies = name, []
options.each { |k, v| send("#{k}=", v) }
end
def link_with=(targets)
@link_with = targets.is_a?(Array) ? targets : [targets]
end end
def lib_name def lib_name
...@@ -59,6 +66,10 @@ module Pod ...@@ -59,6 +66,10 @@ module Pod
platform ? @platform = Platform.new(platform, options) : @platform platform ? @platform = Platform.new(platform, options) : @platform
end end
def link_with(targets = nil)
targets ? @target_definition.link_with = targets : @target_definition.link_with
end
# Specifies a dependency of the project. # Specifies a dependency of the project.
# #
# A dependency requirement is defined by the name of the Pod and _optionally_ # A dependency requirement is defined by the name of the Pod and _optionally_
...@@ -156,8 +167,8 @@ module Pod ...@@ -156,8 +167,8 @@ module Pod
@target_definition.target_dependencies << Dependency.new(*name_and_version_requirements, &block) @target_definition.target_dependencies << Dependency.new(*name_and_version_requirements, &block)
end end
# Specifies that a BridgeSupport metadata should be generated from the # Specifies that a BridgeSupport metadata document should be generated from
# headers of all installed Pods. # the headers of all installed Pods.
# #
# This is for scripting languages such as MacRuby, Nu, and JSCocoa, which use # This is for scripting languages such as MacRuby, Nu, and JSCocoa, which use
# it to bridge types, functions, etc better. # it to bridge types, functions, etc better.
...@@ -193,7 +204,8 @@ module Pod ...@@ -193,7 +204,8 @@ module Pod
# dependency (JSONKit). # dependency (JSONKit).
def target(name, options = {}) def target(name, options = {})
parent = @target_definition parent = @target_definition
@target_definitions[name] = @target_definition = TargetDefinition.new(name, options[:exclusive] ? nil : parent) options[:parent] = parent unless options.delete(:exclusive)
@target_definitions[name] = @target_definition = TargetDefinition.new(name, options)
yield yield
ensure ensure
@target_definition = parent @target_definition = parent
......
...@@ -74,7 +74,7 @@ describe "Pod::Podfile" do ...@@ -74,7 +74,7 @@ describe "Pod::Podfile" do
dependency 'SSZipArchive' dependency 'SSZipArchive'
end end
target :test, :exclusive => true do target :test, :exclusive => true, :link_with => 'TestRunner' do
dependency 'JSONKit' dependency 'JSONKit'
target :subtarget do target :subtarget do
dependency 'Reachability' dependency 'Reachability'
...@@ -115,6 +115,16 @@ describe "Pod::Podfile" do ...@@ -115,6 +115,16 @@ describe "Pod::Podfile" do
target.lib_name.should == 'Pods-test-subtarget' target.lib_name.should == 'Pods-test-subtarget'
target.dependencies.should == [Pod::Dependency.new('Reachability'), Pod::Dependency.new('JSONKit')] target.dependencies.should == [Pod::Dependency.new('Reachability'), Pod::Dependency.new('JSONKit')]
end end
it "leaves the name of the target, to link with, to be automatically resolved" do
target = @podfile.target_definitions[:default]
target.link_with.should == nil
end
it "returns the name of the explicit target to link with" do
target = @podfile.target_definitions[:test]
target.link_with.should == ['TestRunner']
end
end end
describe "concerning validations" do 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