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
end.flatten)
end
def bridge_support_filename
"#{@target_definition.label}.bridgesupport"
# TODO This has to be removed, but this means the specs have to be updated if they need a reference to the prefix header.
def prefix_header_filename
@target_definition.prefix_header_name
end
# TODO move out to Generator::PrefixHeader
......@@ -85,10 +86,10 @@ module Pod
def create_files(pods, sandbox)
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?
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
puts "* Generating xcconfig file at `#{sandbox.root + @target_definition.xcconfig_name}'" if config.verbose?
xcconfig.save_as(sandbox.root + @target_definition.xcconfig_name)
......
......@@ -40,6 +40,10 @@ module Pod
"#{label}-prefix.pch"
end
def bridge_support_name
"#{label}.bridgesupport"
end
# Returns *all* dependencies of this target, not only the target specific
# ones in `target_dependencies`.
def dependencies
......
......@@ -66,11 +66,19 @@ module Pod
add_copy_resources_script_phase
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
# the Pods lib should be linked with.
def targets
if link_with = @target_definition.link_with
@integrator.user_project.targets.select do |target|
@target_definition.link_with.include? target.name
link_with.include? target.name
end
else
[@integrator.user_project.targets.first]
end
end
......
......@@ -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
@integrator.targets.map(&:target_definition).should == @podfile.target_definitions.values
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
describe Pod::Project::Integrator do
......
......@@ -371,18 +371,16 @@ else
project = Pod::Project.new(projpath)
libPods = project.files.find { |f| f.name == 'libPods.a' }
project.targets.each do |target|
target = project.targets.first
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.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
podfile = Pod::Podfile.new do
......
......@@ -145,6 +145,11 @@ describe "Pod::Podfile" do
@podfile.target_definitions[:default].prefix_header_name.should == 'Pods-prefix.pch'
@podfile.target_definitions[:test].prefix_header_name.should == 'Pods-test-prefix.pch'
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
describe "concerning validations" do
......
......@@ -5,7 +5,7 @@ TMP_POD_ROOT = ROOT + "tmp" + "podroot"
describe Pod::Installer::TargetInstaller do
before do
@target_definition = stub('target', :lib_name => "FooLib")
@target_definition = Pod::Podfile::TargetDefinition.new(:foo)
platform = Pod::Platform.new(:ios)
@podfile = stub('podfile', :platform => platform, :generate_bridge_support? => false)
......@@ -27,7 +27,7 @@ describe Pod::Installer::TargetInstaller do
it 'adds a new static library target to the project' do
do_install!
@project.targets.count.should == 1
@project.targets.first.name.should == "FooLib"
@project.targets.first.name.should == @target_definition.label
end
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