Commit 4fefee1f authored by Eloy Duran's avatar Eloy Duran

Create an Xcode project for the platform that’s specified in the Podfile.

parent 6f2f1499
* The user *has* to specify the platform of the project in the Podfile. * The user *has* to specify the platform of the project in the Podfile.
* Based on the platform setting of the Podfile the appropriate xcode project template should be used.
...@@ -43,7 +43,7 @@ module Pod ...@@ -43,7 +43,7 @@ module Pod
end end
def xcodeproj def xcodeproj
@xcodeproj ||= Xcode::Project.ios_static_library @xcodeproj ||= Xcode::Project.static_library(@specification.platform)
end end
def generate_project def generate_project
......
...@@ -223,9 +223,15 @@ module Pod ...@@ -223,9 +223,15 @@ module Pod
file = $LOADED_FEATURES.find { |file| file =~ %r{cocoapods/xcode/project\.rbo?$} } file = $LOADED_FEATURES.find { |file| file =~ %r{cocoapods/xcode/project\.rbo?$} }
TEMPLATES_DIR = Pathname.new(::File.expand_path('../../../../xcode-project-templates', file)) TEMPLATES_DIR = Pathname.new(::File.expand_path('../../../../xcode-project-templates', file))
# TODO see if we really need different templates for iOS and OS X def self.static_library(platform)
def self.ios_static_library case platform
new TEMPLATES_DIR + 'cocoa-touch-static-library' when :osx
new TEMPLATES_DIR + 'cocoa-static-library'
when :ios
new TEMPLATES_DIR + 'cocoa-touch-static-library'
else
raise "No Xcode project template exists for the platform `#{platform.inspect}'"
end
end end
def initialize(template_dir) def initialize(template_dir)
......
...@@ -24,88 +24,94 @@ end ...@@ -24,88 +24,94 @@ end
unless SpecHelper.fixture('integration/ASIHTTPRequest/Classes').exist? unless SpecHelper.fixture('integration/ASIHTTPRequest/Classes').exist?
puts "[!] You must run `git submodule update --init` for the integration spec to work, skipping." puts "[!] You must run `git submodule update --init` for the integration spec to work, skipping."
else else
describe "A full (integration spec) installation" do [:ios, :osx].each do |platform|
extend SpecHelper::TemporaryDirectory describe "A full (integration spec) installation for platform `#{platform}'" do
extend SpecHelper::TemporaryDirectory
before do
Pod::Source.reset! before do
Pod::Spec::Set.reset! Pod::Source.reset!
fixture('spec-repos/master') # ensure the archive is unpacked Pod::Spec::Set.reset!
config.repos_dir = fixture('spec-repos') fixture('spec-repos/master') # ensure the archive is unpacked
config.project_pods_root = temporary_directory + 'Pods' config.repos_dir = fixture('spec-repos')
FileUtils.cp_r(fixture('integration/.'), config.project_pods_root) config.project_pods_root = temporary_directory + 'Pods'
Dir.chdir(config.project_pods_root.to_s) do FileUtils.cp_r(fixture('integration/.'), config.project_pods_root)
FileUtils.mv('ASIHTTPRequest', 'ASIHTTPRequest-1.8.1') Dir.chdir(config.project_pods_root.to_s) do
FileUtils.mv('JSONKit', 'JSONKit-1.4') FileUtils.mv('ASIHTTPRequest', 'ASIHTTPRequest-1.8.1')
FileUtils.mv('SSZipArchive', 'SSZipArchive-1.0') FileUtils.mv('JSONKit', 'JSONKit-1.4')
FileUtils.mv('SSZipArchive', 'SSZipArchive-1.0')
end
end end
end
after do
config.project_pods_root = nil
config.repos_dir = SpecHelper.tmp_repos_path
end
# TODO add a simple source file which uses the compiled lib to check that it really really works after do
it "should activate required pods and create a working static library xcode project" do config.project_pods_root = nil
spec = Pod::Spec.new do |s| config.repos_dir = SpecHelper.tmp_repos_path
s.dependency 'ASIWebPageRequest', '>= 1.8.1'
s.dependency 'JSONKit', '>= 1.0'
s.dependency 'SSZipArchive', '< 2'
end end
installer = SpecHelper::Installer.new(spec) # TODO add a simple source file which uses the compiled lib to check that it really really works
installer.install! it "should activate required pods and create a working static library xcode project" do
spec = Pod::File.new do |s|
s.platform = platform
s.dependency 'ASIWebPageRequest', '>= 1.8.1'
s.dependency 'JSONKit', '>= 1.0'
s.dependency 'SSZipArchive', '< 2'
end
root = config.project_pods_root installer = SpecHelper::Installer.new(spec)
(root + 'Reachability.podspec').should.exist installer.install!
(root + 'ASIHTTPRequest.podspec').should.exist
(root + 'ASIWebPageRequest.podspec').should.exist
(root + 'JSONKit.podspec').should.exist
(root + 'SSZipArchive.podspec').should.exist
(root + 'Pods.xcconfig').read.should == installer.xcconfig.to_s root = config.project_pods_root
(root + 'Reachability.podspec').should.exist
(root + 'ASIHTTPRequest.podspec').should.exist
(root + 'ASIWebPageRequest.podspec').should.exist
(root + 'JSONKit.podspec').should.exist
(root + 'SSZipArchive.podspec').should.exist
project_file = (root + 'Pods.xcodeproj/project.pbxproj').to_s (root + 'Pods.xcconfig').read.should == installer.xcconfig.to_s
NSDictionary.dictionaryWithContentsOfFile(project_file).should == installer.xcodeproj.to_hash
#puts "\n[!] Compiling static library..." project_file = (root + 'Pods.xcodeproj/project.pbxproj').to_s
#Dir.chdir(config.project_pods_root) do NSDictionary.dictionaryWithContentsOfFile(project_file).should == installer.xcodeproj.to_hash
#system("xcodebuild > /dev/null 2>&1").should == true
#system("xcodebuild").should == true
#end
end
it "does not activate pods that are only part of other pods" do #puts "\n[!] Compiling static library..."
spec = Pod::Spec.new do |s| #Dir.chdir(config.project_pods_root) do
s.dependency 'Reachability' #system("xcodebuild > /dev/null 2>&1").should == true
#system("xcodebuild").should == true
#end
end end
installer = SpecHelper::Installer.new(spec) it "does not activate pods that are only part of other pods" do
installer.install! spec = Pod::File.new do |s|
s.platform = platform
s.dependency 'Reachability'
end
(config.project_pods_root + 'Reachability.podspec').should.exist installer = SpecHelper::Installer.new(spec)
(config.project_pods_root + 'ASIHTTPRequest.podspec').should.not.exist installer.install!
end
# TODO we need to do more cleaning and/or add a --prune task (config.project_pods_root + 'Reachability.podspec').should.exist
it "overwrites an existing project.pbxproj file" do (config.project_pods_root + 'ASIHTTPRequest.podspec').should.not.exist
spec = Pod::Spec.new do |s|
s.dependency 'JSONKit'
end end
installer = SpecHelper::Installer.new(spec)
installer.install!
Pod::Source.reset! # TODO we need to do more cleaning and/or add a --prune task
Pod::Spec::Set.reset! it "overwrites an existing project.pbxproj file" do
spec = Pod::Spec.new do |s| spec = Pod::File.new do |s|
s.dependency 'SSZipArchive' s.platform = platform
end s.dependency 'JSONKit'
installer = SpecHelper::Installer.new(spec) end
installer.install! installer = SpecHelper::Installer.new(spec)
installer.install!
Pod::Source.reset!
Pod::Spec::Set.reset!
spec = Pod::File.new do |s|
s.platform = platform
s.dependency 'SSZipArchive'
end
installer = SpecHelper::Installer.new(spec)
installer.install!
project = Pod::Xcode::Project.new(config.project_pods_root) project = Pod::Xcode::Project.new(config.project_pods_root)
project.source_files.sort.should == Pod::Installer.new(spec).source_files.sort project.source_files.sort.should == Pod::Installer.new(spec).source_files.sort
end
end end
end end
end end
...@@ -55,7 +55,11 @@ describe "Pod::Installer" do ...@@ -55,7 +55,11 @@ describe "Pod::Installer" do
Pod::Source.reset! Pod::Source.reset!
Pod::Spec::Set.reset! Pod::Spec::Set.reset!
installer = Pod::Installer.new(Pod::Spec.new { |s| s.dependency(name); s.source_files = *patterns }) installer = Pod::Installer.new(Pod::Spec.new do |s|
s.platform = :ios
s.dependency(name)
s.source_files = *patterns
end)
destroot = stubbed_destroot(installer) destroot = stubbed_destroot(installer)
installer.generate_project installer.generate_project
......
...@@ -4,7 +4,7 @@ describe "Pod::Xcode::Project" do ...@@ -4,7 +4,7 @@ describe "Pod::Xcode::Project" do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
before do before do
@project = Pod::Xcode::Project.ios_static_library @project = Pod::Xcode::Project.static_library(:ios)
end end
def find_objects(conditions) def find_objects(conditions)
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
518ACD53144605B400F6BE80 /* Pods.xcconfig */, 518ACD53144605B400F6BE80 /* Pods.xcconfig */,
518ACD441446050200F6BE80 /* Pods */, 518ACD5B1446449B00F6BE80 /* Pods */,
518ACD3D1446050200F6BE80 /* Frameworks */, 518ACD3D1446050200F6BE80 /* Frameworks */,
518ACD3C1446050200F6BE80 /* Products */, 518ACD3C1446050200F6BE80 /* Products */,
); );
...@@ -55,20 +55,21 @@ ...@@ -55,20 +55,21 @@
name = Frameworks; name = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
518ACD441446050200F6BE80 /* Pods */ = { 518ACD451446050200F6BE80 /* Supporting Files */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
518ACD451446050200F6BE80 /* Supporting Files */, 518ACD461446050200F6BE80 /* Pods-Prefix.pch */,
); );
name = "Supporting Files";
path = Pods; path = Pods;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
518ACD451446050200F6BE80 /* Supporting Files */ = { 518ACD5B1446449B00F6BE80 /* Pods */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
518ACD461446050200F6BE80 /* Pods-Prefix.pch */, 518ACD451446050200F6BE80 /* Supporting Files */,
); );
name = "Supporting Files"; name = Pods;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
/* End PBXGroup section */ /* End PBXGroup section */
......
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