Permalink
Browse files

Merge pull request #466 from CocoaPods/subspec_groups

[Project] Namespace subspecs in groups.
  • Loading branch information...
2 parents e8d6f12 + 647a397 commit e6505274cb09cf690eca68910dfed41a5ce82611 @alloy alloy committed Aug 21, 2012
Showing with 35 additions and 7 deletions.
  1. +5 −3 lib/cocoapods/installer.rb
  2. +9 −0 lib/cocoapods/local_pod.rb
  3. +9 −3 lib/cocoapods/project.rb
  4. +12 −1 spec/unit/project_spec.rb
View
8 lib/cocoapods/installer.rb
@@ -28,9 +28,11 @@ def project
@project.user_build_configurations = @podfile.user_build_configurations
pods.each do |pod|
# Add all source files to the project grouped by pod
- group = @project.add_pod_group(pod.name)
- pod.relative_source_files.each do |path|
- group.files.new('path' => path.to_s)
+ pod.relative_source_files_by_spec.each do |spec, paths|
+ group = @project.add_spec_group(spec.name)
+ paths.each do |path|
+ group.files.new('path' => path.to_s)
+ end
end
end
# Add a group to hold all the target support files
View
9 lib/cocoapods/local_pod.rb
@@ -192,6 +192,15 @@ def relative_source_files
source_files.map{ |p| p.relative_path_from(@sandbox.root) }
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.
#
# @note If the same file is required by two specifications the one at the
View
12 lib/cocoapods/project.rb
@@ -34,9 +34,15 @@ def pods
groups.find { |g| g.name == 'Pods' } || groups.new({ 'name' => 'Pods' })
end
- # Adds a group as child to the `Pods' group.
- def add_pod_group(name)
- pods.groups.new('name' => name)
+ # Adds a group as child to the `Pods' group namespacing subspecs.
+ def add_spec_group(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
def add_pod_target(name, platform)
View
13 spec/unit/project_spec.rb
@@ -12,7 +12,7 @@ def find_object(conditions)
end
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
find_object({
'isa' => 'PBXGroup',
@@ -22,6 +22,17 @@ def find_object(conditions)
}).should.not == nil
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
@project.targets.new
phase = @project.targets.first.copy_files_build_phases.new_pod_dir("SomePod", "Path/To/Source")

0 comments on commit e650527

Please sign in to comment.