Commit e08a67a6 authored by Nolan Waite's avatar Nolan Waite

Template maintains its project

parent 5129dcdc
......@@ -133,31 +133,26 @@ module Pod
end
def template
@template ||= ProjectTemplate.new(@podfile.platform)
end
def xcodeproj
unless @xcodeproj
@xcodeproj = Xcode::Project.new(template.xcodeproj_path)
# First we need to resolve dependencies across *all* targets, so that the
# same correct versions of pods are being used for all targets. This
# happens when we call `build_specifications'.
build_specifications.each do |spec|
# Add all source files to the project grouped by pod
group = xcodeproj.add_pod_group(spec.name)
spec.expanded_source_files.each do |path|
group.children.new('path' => path.to_s)
end
return @template if @template
@template = ProjectTemplate.new(@podfile.platform)
# First we need to resolve dependencies across *all* targets, so that the
# same correct versions of pods are being used for all targets. This
# happens when we call `build_specifications'.
build_specifications.each do |spec|
# Add all source files to the project grouped by pod
group = @template.project.add_pod_group(spec.name)
spec.expanded_source_files.each do |path|
group.children.new('path' => path.to_s)
end
# Add a group to hold all the target support files
xcodeproj.main_group.groups.new('name' => 'Targets Support Files')
end
@xcodeproj
# Add a group to hold all the target support files
@template.project.main_group.groups.new('name' => 'Targets Support Files')
@template
end
def targets
@targets ||= @podfile.targets.values.map do |target_definition|
Target.new(@podfile, xcodeproj, target_definition)
Target.new(@podfile, template.project, target_definition)
end
end
......@@ -176,7 +171,7 @@ module Pod
end
pbxproj = File.join(root, 'Pods.xcodeproj')
puts " * Writing Xcode project file to `#{pbxproj}'" if config.verbose?
xcodeproj.save_as(pbxproj)
template.project.save_as(pbxproj)
# Post install hooks run last!
targets.each do |target|
......
......@@ -4,8 +4,11 @@ module Pod
class ProjectTemplate
def initialize(platform)
@platform = platform
@project = Xcode::Project.new(File.join(path, 'Pods.xcodeproj'))
end
attr_reader :project
# TODO this is a workaround for an issue with MacRuby with compiled files
# that makes the use of __FILE__ impossible.
#
......@@ -34,12 +37,9 @@ module Pod
end
end
def xcodeproj_path
@xcodeproj_path = File.join(path, 'Pods.xcodeproj')
end
def copy_to(pods_root)
FileUtils.cp_r("#{path}/.", pods_root)
@project.save_as(File.join(pods_root, 'Pods.xcodeproj'))
end
end
end
......@@ -77,7 +77,7 @@ else
(root + 'Pods.xcconfig').read.should == installer.targets.first.xcconfig.to_s
project_file = (root + 'Pods.xcodeproj/project.pbxproj').to_s
NSDictionary.dictionaryWithContentsOfFile(project_file).should == installer.xcodeproj.to_hash
NSDictionary.dictionaryWithContentsOfFile(project_file).should == installer.template.project.to_hash
puts "\n[!] Compiling static library..."
Dir.chdir(config.project_pods_root) do
......@@ -144,7 +144,7 @@ else
installer.install!
project = Pod::Xcode::Project.new(config.project_pods_root + 'Pods.xcodeproj')
project.source_files.should == installer.xcodeproj.source_files
project.source_files.should == installer.template.project.source_files
end
it "creates a project with multiple targets" do
......
This diff is collapsed.
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