Commit e1f9b5d7 authored by Eloy Duran's avatar Eloy Duran

If no explicit target to link with is specified, then use the first target from the user's project.

parent 02a52101
...@@ -31,8 +31,9 @@ module Pod ...@@ -31,8 +31,9 @@ module Pod
end.flatten) end.flatten)
end end
def bridge_support_filename # TODO This has to be removed, but this means the specs have to be updated if they need a reference to the prefix header.
"#{@target_definition.label}.bridgesupport" def prefix_header_filename
@target_definition.prefix_header_name
end end
# TODO move out to Generator::PrefixHeader # TODO move out to Generator::PrefixHeader
...@@ -85,10 +86,10 @@ module Pod ...@@ -85,10 +86,10 @@ module Pod
def create_files(pods, sandbox) def create_files(pods, sandbox)
if @podfile.generate_bridge_support? if @podfile.generate_bridge_support?
bridge_support_metadata_path = sandbox.root + bridge_support_filename bridge_support_metadata_path = sandbox.root + @target_definition.bridge_support_name
puts "* Generating BridgeSupport metadata file at `#{bridge_support_metadata_path}'" if config.verbose? puts "* Generating BridgeSupport metadata file at `#{bridge_support_metadata_path}'" if config.verbose?
bridge_support_generator_for(pods, sandbox).save_as(bridge_support_metadata_path) bridge_support_generator_for(pods, sandbox).save_as(bridge_support_metadata_path)
copy_resources_script_for(pods).resources << bridge_support_filename copy_resources_script_for(pods).resources << @target_definition.bridge_support_name
end end
puts "* Generating xcconfig file at `#{sandbox.root + @target_definition.xcconfig_name}'" if config.verbose? puts "* Generating xcconfig file at `#{sandbox.root + @target_definition.xcconfig_name}'" if config.verbose?
xcconfig.save_as(sandbox.root + @target_definition.xcconfig_name) xcconfig.save_as(sandbox.root + @target_definition.xcconfig_name)
......
...@@ -40,6 +40,10 @@ module Pod ...@@ -40,6 +40,10 @@ module Pod
"#{label}-prefix.pch" "#{label}-prefix.pch"
end end
def bridge_support_name
"#{label}.bridgesupport"
end
# Returns *all* dependencies of this target, not only the target specific # Returns *all* dependencies of this target, not only the target specific
# ones in `target_dependencies`. # ones in `target_dependencies`.
def dependencies def dependencies
......
...@@ -66,11 +66,19 @@ module Pod ...@@ -66,11 +66,19 @@ module Pod
add_copy_resources_script_phase add_copy_resources_script_phase
end end
# This returns a list of the targets from the user’s project to which
# this Pods static library should be linked. If no explicit target was
# specified, then the first encountered target is assumed.
#
# @return [Array<PBXNativeTarget>] Returns the list of targets that # @return [Array<PBXNativeTarget>] Returns the list of targets that
# the Pods lib should be linked with. # the Pods lib should be linked with.
def targets def targets
@integrator.user_project.targets.select do |target| if link_with = @target_definition.link_with
@target_definition.link_with.include? target.name @integrator.user_project.targets.select do |target|
link_with.include? target.name
end
else
[@integrator.user_project.targets.first]
end end
end end
......
...@@ -33,6 +33,12 @@ describe Pod::Project::Integrator, 'TODO UNIT SPECS!' do ...@@ -33,6 +33,12 @@ describe Pod::Project::Integrator, 'TODO UNIT SPECS!' do
it "returns a Pod::Project::Integrator::Target for each target definition in the Podfile" do it "returns a Pod::Project::Integrator::Target for each target definition in the Podfile" do
@integrator.targets.map(&:target_definition).should == @podfile.target_definitions.values @integrator.targets.map(&:target_definition).should == @podfile.target_definitions.values
end end
it "uses the first target in the user's project if no explicit target is specified" do
target_integrator = @integrator.targets.first
target_integrator.target_definition.stubs(:link_with).returns(nil)
target_integrator.targets.should == [Xcodeproj::Project.new(@sample_project_path).targets.first]
end
end end
describe Pod::Project::Integrator do describe Pod::Project::Integrator do
......
...@@ -371,17 +371,15 @@ else ...@@ -371,17 +371,15 @@ else
project = Pod::Project.new(projpath) project = Pod::Project.new(projpath)
libPods = project.files.find { |f| f.name == 'libPods.a' } libPods = project.files.find { |f| f.name == 'libPods.a' }
project.targets.each do |target|
target.build_configurations.each do |config|
config.base_configuration.path.should == 'Pods/Pods.xcconfig'
end
phase = target.frameworks_build_phases.first
phase.files.map { |build_file| build_file.file }.should.include libPods
# should be the last phase target = project.targets.first
target.build_phases.last.shell_script.should == %{"${SRCROOT}/Pods/Pods-resources.sh"\n} target.build_configurations.each do |config|
config.base_configuration.path.should == 'Pods/Pods.xcconfig'
end end
phase = target.frameworks_build_phases.first
phase.files.map { |build_file| build_file.file }.should.include libPods
# should be the last phase
target.build_phases.last.shell_script.should == %{"${SRCROOT}/Pods/Pods-resources.sh"\n}
end end
it "should prevent duplication cleaning headers symlinks with multiple targets" do it "should prevent duplication cleaning headers symlinks with multiple targets" do
......
...@@ -145,6 +145,11 @@ describe "Pod::Podfile" do ...@@ -145,6 +145,11 @@ describe "Pod::Podfile" do
@podfile.target_definitions[:default].prefix_header_name.should == 'Pods-prefix.pch' @podfile.target_definitions[:default].prefix_header_name.should == 'Pods-prefix.pch'
@podfile.target_definitions[:test].prefix_header_name.should == 'Pods-test-prefix.pch' @podfile.target_definitions[:test].prefix_header_name.should == 'Pods-test-prefix.pch'
end end
it "returns the name of the BridgeSupport file for the target" do
@podfile.target_definitions[:default].bridge_support_name.should == 'Pods.bridgesupport'
@podfile.target_definitions[:test].bridge_support_name.should == 'Pods-test.bridgesupport'
end
end end
describe "concerning validations" do describe "concerning validations" do
......
...@@ -5,7 +5,7 @@ TMP_POD_ROOT = ROOT + "tmp" + "podroot" ...@@ -5,7 +5,7 @@ TMP_POD_ROOT = ROOT + "tmp" + "podroot"
describe Pod::Installer::TargetInstaller do describe Pod::Installer::TargetInstaller do
before do before do
@target_definition = stub('target', :lib_name => "FooLib") @target_definition = Pod::Podfile::TargetDefinition.new(:foo)
platform = Pod::Platform.new(:ios) platform = Pod::Platform.new(:ios)
@podfile = stub('podfile', :platform => platform, :generate_bridge_support? => false) @podfile = stub('podfile', :platform => platform, :generate_bridge_support? => false)
...@@ -27,7 +27,7 @@ describe Pod::Installer::TargetInstaller do ...@@ -27,7 +27,7 @@ describe Pod::Installer::TargetInstaller do
it 'adds a new static library target to the project' do it 'adds a new static library target to the project' do
do_install! do_install!
@project.targets.count.should == 1 @project.targets.count.should == 1
@project.targets.first.name.should == "FooLib" @project.targets.first.name.should == @target_definition.label
end end
it 'adds each pod to the static library target' do it 'adds each pod to the static library target' 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