Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Project] Namespace subspecs in groups. #466

Merged
merged 1 commit into from Aug 21, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/cocoapods/installer.rb
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions lib/cocoapods/local_pod.rb
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions lib/cocoapods/project.rb
Expand Up @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion spec/unit/project_spec.rb
Expand Up @@ -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',
Expand All @@ -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")
Expand Down