Commit e08a67a6 authored by Nolan Waite's avatar Nolan Waite

Template maintains its project

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