Commit 1ab7a6ff authored by Per Eckerdal's avatar Per Eckerdal

Add support for multiple Xcode subprojects per spec

Because it makes sense.
parent ce3b4a30
......@@ -63,11 +63,9 @@ module Pod
# @return [void]
#
def add_libraries_to_target
pod_target.spec_consumers.each do |consumer|
xcodeproj = consumer.xcodeproj
next unless xcodeproj['project']
pod_target.spec_consumers.map do |consumer|
xcodeprojs_from_consumer(consumer)
end.flatten.each do |xcodeproj|
linked_project = open_linked_xcode_project(xcodeproj['project'])
# Hide the schemes that would be autogenerated for the subproject's targets.
......@@ -142,15 +140,13 @@ module Pod
def linked_project_specs
specs_by_path = {}
pod_target.spec_consumers.each do |consumer|
proj = consumer.xcodeproj
next unless proj.present?
absolute_path = pod_root + proj['project']
pod_target.spec_consumers.map do |consumer|
xcodeprojs_from_consumer(consumer).each do |proj|
absolute_path = pod_root + proj['project']
specs_by_path[absolute_path] ||= []
specs_by_path[absolute_path] << consumer.spec
specs_by_path[absolute_path] ||= []
specs_by_path[absolute_path] << consumer.spec
end
end
specs_by_path
......@@ -177,6 +173,30 @@ module Pod
target
end
# Takes a Consumer and extracts an array of xcodeproj descriptors.
#
# @param [Specification::Consumer] consumer The consumer to take xcodeprojs from
#
# @return [Array<Hash>] A list of valid xcodeproj specifications
#
def xcodeprojs_from_consumer(consumer)
xcodeprojs = consumer.xcodeprojs
xcodeprojs = [] if xcodeprojs.nil?
xcodeprojs = [xcodeprojs] if xcodeprojs.kind_of?(Hash)
xcodeprojs = xcodeprojs.map do |xcodeproj|
xcodeproj.inject({}) { |memo, (k,v)| memo[k.to_s] = v; memo }
end
xcodeprojs.each do |xcodeproj|
unless xcodeproj.has_key?('project')
raise Informative, "Missing project parameter to xcodeproj specification: #{xcodeproj.inspect}"
end
end
xcodeprojs
end
# @return [String] the path where the pod target's specification is
# defined, if loaded from a file. (May be nil)
#
......
......@@ -232,7 +232,7 @@ module Pod
#
def clean_paths
has_xcodeproj = specs_by_platform.any? do |platform, specs|
specs.any? { |spec| spec.consumer(platform).xcodeproj.present? }
specs.any? { |spec| spec.consumer(platform).xcodeprojs.present? }
end
return [] if has_xcodeproj
......
......@@ -145,6 +145,20 @@ module Pod
end.message.should.match /Could not find native target/
end
it "extracts a single xcodeproj from a consumer object" do
spec = @file_accessor.spec
spec.xcodeproj = { :project => 'hello' }
@installer.send(:xcodeprojs_from_consumer, spec.consumer(:ios)).should.be == [{ "project" => "hello" }]
end
it "extracts two xcodeprojs from a consumer object" do
spec = @file_accessor.spec
spec.xcodeprojs = [{ :project => 'hello' }, { 'project' => 'hello2' }]
xcodeprojs = @installer.send(:xcodeprojs_from_consumer, spec.consumer(:ios))
xcodeprojs.should.be == [{ "project" => "hello" }, { "project" => "hello2" }]
end
it "finds the spec file path correctly" do
@installer.send(:spec_file).should.be == @file_accessor.spec.defined_in_file
end
......
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