Commit 2182e471 authored by Luke Redpath's avatar Luke Redpath

Let's make Pod::Project a class in it's own right, inheriting from Xcodeproj::Project, instead

of extending it.
parent 8a73c7d3
......@@ -14,6 +14,7 @@ module Pod
autoload :LocalPod, 'cocoapods/local_pod'
autoload :Platform, 'cocoapods/platform'
autoload :Podfile, 'cocoapods/podfile'
autoload :Project, 'cocoapods/project'
autoload :Resolver, 'cocoapods/resolver'
autoload :Sandbox, 'cocoapods/sandbox'
autoload :Source, 'cocoapods/source'
......@@ -30,12 +31,6 @@ module Pod
end
end
module Xcodeproj
autoload :Config, 'xcodeproj/config'
autoload :Project, 'cocoapods/xcodeproj_pods'
autoload :Workspace, 'xcodeproj/workspace'
end
class Pathname
def glob(pattern = '')
Dir.glob((self + pattern).to_s).map { |f| Pathname.new(f) }
......
......@@ -34,7 +34,7 @@ module Pod
def project
return @project if @project
@project = Xcodeproj::Project.for_platform(@podfile.platform)
@project = Pod::Project.for_platform(@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'.
......@@ -162,7 +162,7 @@ module Pod
end
workspace.save_as(xcworkspace)
app_project = Xcodeproj::Project.new(projpath)
app_project = Pod::Project.new(projpath)
return if app_project.files.find { |file| file.path =~ /libPods\.a$/ }
configfile = app_project.files.new('path' => 'Pods/Pods.xcconfig')
......
require 'xcodeproj/project'
module Xcodeproj
class Project
Xcodeproj::Project::PBXCopyFilesBuildPhase.instance_eval do
def self.new_pod_dir(project, pod_name, path)
new(project, nil, {
"dstPath" => "Pods/#{path}",
"name" => "Copy #{pod_name} Public Headers",
})
end
end
module Pod
class Project < Xcodeproj::Project
# Shortcut access to the `Pods' PBXGroup.
def pods
groups.find { |g| g.name == 'Pods' } || groups.new({ 'name' => 'Pods' })
......@@ -21,17 +30,8 @@ module Xcodeproj
build_configurations.find { |c| c.name == name }
end
class PBXCopyFilesBuildPhase
def self.new_pod_dir(project, pod_name, path)
new(project, nil, {
"dstPath" => "Pods/#{path}",
"name" => "Copy #{pod_name} Public Headers",
})
end
end
def self.for_platform(platform)
project = Xcodeproj::Project.new
project = Pod::Project.new
project.main_group << project.groups.new({ 'name' => 'Pods' })
framework = project.add_system_framework(platform == :ios ? 'Foundation' : 'Cocoa')
framework.group = project.groups.new({ 'name' => 'Frameworks' })
......
require 'xcodeproj/config'
module Pod
extend Config::Mixin
......
......@@ -143,7 +143,7 @@ else
end
SpecHelper::Installer.new(podfile).install!
project = Xcodeproj::Project.new(config.project_pods_root + 'Pods.xcodeproj')
project = Pod::Project.new(config.project_pods_root + 'Pods.xcodeproj')
project.targets.first.buildConfigurations.map do |config|
config.buildSettings['GCC_ENABLE_OBJC_GC']
end.should == %w{ supported supported }
......@@ -262,7 +262,7 @@ else
installer = SpecHelper::Installer.new(spec)
installer.install!
project = Xcodeproj::Project.new(config.project_pods_root + 'Pods.xcodeproj')
project = Pod::Project.new(config.project_pods_root + 'Pods.xcodeproj')
project.source_files.should == installer.project.source_files
end
......@@ -322,7 +322,7 @@ else
workspace = Xcodeproj::Workspace.new_from_xcworkspace(xcworkspace)
workspace.projpaths.sort.should == ['ASIHTTPRequest.xcodeproj', 'Pods/Pods.xcodeproj']
project = Xcodeproj::Project.new(projpath)
project = Pod::Project.new(projpath)
libPods = project.files.find { |f| f.name == 'libPods.a' }
project.targets.each do |target|
target.buildConfigurations.each do |config|
......
require File.expand_path('../../spec_helper', __FILE__)
describe 'Xcodeproj::Project' do
describe 'Pod::Project' do
before do
@project = Xcodeproj::Project.new
@project = Pod::Project.new
end
def find_object(conditions)
......@@ -42,7 +42,7 @@ describe 'Xcodeproj::Project' do
describe "for the :ios platform" do
before do
@project = Xcodeproj::Project.for_platform(Pod::Platform.new(:ios))
@project = Pod::Project.for_platform(Pod::Platform.new(:ios))
end
behaves_like "for any platform"
......@@ -54,35 +54,35 @@ describe 'Xcodeproj::Project' do
describe "for the :ios platform with a deployment target" do
it "sets ARCHS to 'armv6 armv7' for both configurations if the deployment target is less than 4.3" do
@project = Xcodeproj::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.0"))
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.0"))
@project.build_configuration("Debug").buildSettings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").buildSettings["ARCHS"].should == "armv6 armv7"
@project = Xcodeproj::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.1"))
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.1"))
@project.build_configuration("Debug").buildSettings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").buildSettings["ARCHS"].should == "armv6 armv7"
@project = Xcodeproj::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.2"))
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.2"))
@project.build_configuration("Debug").buildSettings["ARCHS"].should == "armv6 armv7"
@project.build_configuration("Release").buildSettings["ARCHS"].should == "armv6 armv7"
end
it "uses standard ARCHs if deployment target is 4.3 or above" do
@project = Xcodeproj::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.3"))
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.3"))
@project.build_configuration("Debug").buildSettings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project.build_configuration("Release").buildSettings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project = Xcodeproj::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.4"))
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.4"))
@project.build_configuration("Debug").buildSettings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
@project.build_configuration("Release").buildSettings["ARCHS"].should == "$(ARCHS_STANDARD_32_BIT)"
end
it "sets IPHONEOS_DEPLOYMENT_TARGET for both configurations" do
@project = Xcodeproj::Project.for_platform(Pod::Platform.new(:ios))
@project = Pod::Project.for_platform(Pod::Platform.new(:ios))
@project.build_configuration("Debug").buildSettings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.3"
@project.build_configuration("Release").buildSettings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.3"
@project = Xcodeproj::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.0"))
@project = Pod::Project.for_platform(Pod::Platform.new(:ios, :deployment_target => "4.0"))
@project.build_configuration("Debug").buildSettings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.0"
@project.build_configuration("Release").buildSettings["IPHONEOS_DEPLOYMENT_TARGET"].should == "4.0"
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