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