Commit e6505274 authored by Eloy Durán's avatar Eloy Durán

Merge pull request #466 from CocoaPods/subspec_groups

[Project] Namespace subspecs in groups.
parents e8d6f12e 647a397a
...@@ -28,9 +28,11 @@ module Pod ...@@ -28,9 +28,11 @@ module Pod
@project.user_build_configurations = @podfile.user_build_configurations @project.user_build_configurations = @podfile.user_build_configurations
pods.each do |pod| pods.each do |pod|
# Add all source files to the project grouped by pod # Add all source files to the project grouped by pod
group = @project.add_pod_group(pod.name) pod.relative_source_files_by_spec.each do |spec, paths|
pod.relative_source_files.each do |path| group = @project.add_spec_group(spec.name)
group.files.new('path' => path.to_s) paths.each do |path|
group.files.new('path' => path.to_s)
end
end end
end end
# Add a group to hold all the target support files # Add a group to hold all the target support files
......
...@@ -192,6 +192,15 @@ module Pod ...@@ -192,6 +192,15 @@ module Pod
source_files.map{ |p| p.relative_path_from(@sandbox.root) } source_files.map{ |p| p.relative_path_from(@sandbox.root) }
end end
def relative_source_files_by_spec
result = {}
source_files_by_spec.each do |spec, paths|
result[spec] = paths.map{ |p| p.relative_path_from(@sandbox.root) }
end
result
end
# Finds the source files that every activated {Specification} requires. # Finds the source files that every activated {Specification} requires.
# #
# @note If the same file is required by two specifications the one at the # @note If the same file is required by two specifications the one at the
......
...@@ -34,9 +34,15 @@ module Pod ...@@ -34,9 +34,15 @@ module Pod
groups.find { |g| g.name == 'Pods' } || groups.new({ 'name' => 'Pods' }) groups.find { |g| g.name == 'Pods' } || groups.new({ 'name' => 'Pods' })
end end
# Adds a group as child to the `Pods' group. # Adds a group as child to the `Pods' group namespacing subspecs.
def add_pod_group(name) def add_spec_group(name)
pods.groups.new('name' => name) groups = pods.groups
group = nil
name.split('/').each do |name|
group = groups.find { |g| g.name == name } || groups.new({ 'name' => name })
groups = group.groups
end
group
end end
def add_pod_target(name, platform) def add_pod_target(name, platform)
......
...@@ -12,7 +12,7 @@ describe 'Pod::Project' do ...@@ -12,7 +12,7 @@ describe 'Pod::Project' do
end end
it "adds a group to the `Pods' group" do it "adds a group to the `Pods' group" do
group = @project.add_pod_group('JSONKit') group = @project.add_spec_group('JSONKit')
@project.pods.child_references.should.include group.uuid @project.pods.child_references.should.include group.uuid
find_object({ find_object({
'isa' => 'PBXGroup', 'isa' => 'PBXGroup',
...@@ -22,6 +22,17 @@ describe 'Pod::Project' do ...@@ -22,6 +22,17 @@ describe 'Pod::Project' do
}).should.not == nil }).should.not == nil
end end
it "namespaces subspecs in groups" do
group = @project.add_spec_group('JSONKit/Subspec')
@project.pods.groups.find { |g| g.name == 'JSONKit' }.child_references.should.include group.uuid
find_object({
'isa' => 'PBXGroup',
'name' => 'Subspec',
'sourceTree' => '<group>',
'children' => []
}).should.not == nil
end
it "creates a copy build header phase which will copy headers to a specified path" do it "creates a copy build header phase which will copy headers to a specified path" do
@project.targets.new @project.targets.new
phase = @project.targets.first.copy_files_build_phases.new_pod_dir("SomePod", "Path/To/Source") phase = @project.targets.first.copy_files_build_phases.new_pod_dir("SomePod", "Path/To/Source")
......
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