Commit 31a02728 authored by Nolan Waite's avatar Nolan Waite

Pod installer creates workspace

parent 41391400
......@@ -89,5 +89,18 @@ module Pod
build_specifications.each(&:post_install)
end
def configure_project(projpath)
root = File.dirname(projpath)
xcworkspace = File.join(root, File.basename(projpath, '.xcodeproj') + '.xcworkspace')
workspace = Xcode::Workspace.new_from_xcworkspace(xcworkspace)
paths = [projpath]
paths << File.join(config.project_pods_root, File.dirname(xcodeproj.template_file))
root = Pathname.new(root).expand_path
paths.each do |path|
workspace << Pathname.new(path).expand_path.relative_path_from(root)
end
workspace.save_as(xcworkspace)
end
end
end
......@@ -8,16 +8,20 @@ module Pod
@projpaths = projpaths
end
def self.from_xcworkspace(path)
from_s(File.read(File.join(path, 'contents.xcworkspacedata')))
def self.new_from_xcworkspace(path)
begin
from_s(File.read(File.join(path, 'contents.xcworkspacedata')))
rescue Errno::ENOENT
new
end
end
def self.from_s(xml)
doc = NSXMLDocument.alloc.initWithXMLString(xml, options:0, error:nil)
projpaths = doc.nodesForXPath("/Workspace/FileRef", error:nil).map do |node|
node.attributeWithName("location").stringValue.sub(/^group:/, '')
node.attributeForName("location").stringValue.sub(/^group:/, '')
end
new(projpaths)
new(*projpaths)
end
attr_reader :projpaths
......@@ -29,7 +33,7 @@ module Pod
TEMPLATE = %q[<?xml version="1.0" encoding="UTF-8"?><Workspace version="1.0"></Workspace>]
def to_s
doc = NSXMLDocument.alloc.initWithXMLString(TEMPLATE, options:0, error:nil)
@projpaths.each do |projpath|
@projpaths.uniq.each do |projpath|
el = NSXMLNode.elementWithName("FileRef")
el.addAttribute(NSXMLNode.attributeWithName("location", stringValue:"group:#{projpath}"))
doc.rootElement.addChild(el)
......
......@@ -131,6 +131,22 @@ else
project = Pod::Xcode::Project.new(config.project_pods_root)
project.source_files.should == installer.xcodeproj.source_files
end
it "sets up an existing project with pods" do
basename = platform == :ios ? 'iPhone' : 'Mac'
projpath = temporary_directory + 'ASIHTTPRequest.xcodeproj'
FileUtils.cp_r(fixture("integration/ASIHTTPRequest/#{basename}.xcodeproj"), projpath)
spec = Pod::Podfile.new do
self.platform platform
dependency 'SSZipArchive'
end
installer = SpecHelper::Installer.new(spec)
installer.install!
installer.configure_project(projpath)
xcworkspace = temporary_directory + 'ASIHTTPRequest.xcworkspace'
workspace = Pod::Xcode::Workspace.new_from_xcworkspace(xcworkspace)
workspace.projpaths.sort.should == ['ASIHTTPRequest.xcodeproj', 'Pods/Pods.xcodeproj']
end
end
end
end
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