From 4a709b8791d0d197aa072b1da5716b51e018cf0a Mon Sep 17 00:00:00 2001 From: Eloy Duran Date: Sun, 1 Apr 2012 20:25:27 +0200 Subject: [PATCH] Make building a iOS lib work again. --- .gitmodules | 3 ++ Gemfile.lock | 2 +- TODO | 2 + lib/cocoapods/installer.rb | 9 ++-- lib/cocoapods/local_pod.rb | 8 +++- lib/cocoapods/resolver.rb | 2 + spec/fixtures/integration/Reachability | 1 + spec/integration_spec.rb | 66 ++++++++++++++++++++------ spec/spec_helper.rb | 3 +- 9 files changed, 74 insertions(+), 22 deletions(-) create mode 160000 spec/fixtures/integration/Reachability diff --git a/.gitmodules b/.gitmodules index 9dc450d..401c08b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "spec/fixtures/spec-repos/master"] path = spec/fixtures/spec-repos/master url = https://github.com/CocoaPods/Specs.git +[submodule "spec/fixtures/integration/Reachability"] + path = spec/fixtures/integration/Reachability + url = https://github.com/tonymillion/Reachability.git diff --git a/Gemfile.lock b/Gemfile.lock index 42ebd2f..7545db4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/CocoaPods/Xcodeproj.git - revision: b3db4601c47bf78cb5e6fa8ada5bcb4cda18e05f + revision: c7a2acb7f49005823a37cea0089e558ff4a13af7 specs: xcodeproj (0.1.0) diff --git a/TODO b/TODO index 1509f36..fea0ef6 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ +* For now, remove ability to set things like link_with and platform through the target options. * Resolve all dependencies together and write out all dependencies to Podfile.lock together. * Add integration spec with multiple platforms. * Validate platforms for each target definition. * Validate that there are dependencies in a Podfile. * Validate that the dependencies in the targets don't conflict. E.g. two different versions of the same pod. +* Move Podfile.lock generator from Installer into its own file. diff --git a/lib/cocoapods/installer.rb b/lib/cocoapods/installer.rb index dc8a286..ebba271 100644 --- a/lib/cocoapods/installer.rb +++ b/lib/cocoapods/installer.rb @@ -1,3 +1,5 @@ +require 'colored' + module Pod class Installer autoload :TargetInstaller, 'cocoapods/installer/target_installer' @@ -47,7 +49,7 @@ module Pod unless should_install = !pod.exists? && !pod.specification.local? puts marker + "Using #{pod}" unless config.silent? else - puts marker + "Installing #{spec}".green unless config.silent? + puts marker + "Installing #{pod.specification}".green unless config.silent? downloader = Downloader.for_pod(pod) downloader.download @@ -111,9 +113,8 @@ module Pod file.puts "PODS:" pods.map do |pod| # TODO this should list _all_ the pods, so merge the platforms - dependencies = pod.specification.dependencies[@podfile.target_definitions[:default].platform.to_sym] - [pod.specification.to_s, dependencies.map(&:to_s).sort] - end.sort_by(&:first).each do |name, deps| + [pod.specification.to_s, pod.dependencies.map(&:to_s).sort] + end.uniq.sort_by(&:first).each do |name, deps| if deps.empty? file.puts " - #{name}" else diff --git a/lib/cocoapods/local_pod.rb b/lib/cocoapods/local_pod.rb index eba6559..aa69432 100644 --- a/lib/cocoapods/local_pod.rb +++ b/lib/cocoapods/local_pod.rb @@ -77,13 +77,17 @@ module Pod def add_to_target(target) implementation_files.each do |file| - target.add_source_file(file, nil, specification.compiler_flags[@platform.to_sym].strip) + target.add_source_file(file, nil, specification.compiler_flags[@platform.name].strip) end end def requires_arc? specification.requires_arc end + + def dependencies + specification.dependencies[@platform.name] + end private @@ -107,7 +111,7 @@ module Pod end def expanded_paths(platforms_with_patterns, options = {}) - patterns = platforms_with_patterns.is_a?(Hash) ? (platforms_with_patterns[@platform.to_sym] || []) : platforms_with_patterns + patterns = platforms_with_patterns.is_a?(Hash) ? platforms_with_patterns[@platform.name] : platforms_with_patterns patterns.map do |pattern| pattern = root + pattern diff --git a/lib/cocoapods/resolver.rb b/lib/cocoapods/resolver.rb index cb2ff39..871b90b 100644 --- a/lib/cocoapods/resolver.rb +++ b/lib/cocoapods/resolver.rb @@ -1,3 +1,5 @@ +require 'colored' + module Pod class Resolver include Config::Mixin diff --git a/spec/fixtures/integration/Reachability b/spec/fixtures/integration/Reachability new file mode 160000 index 0000000..c8a3e52 --- /dev/null +++ b/spec/fixtures/integration/Reachability @@ -0,0 +1 @@ +Subproject commit c8a3e521ee57ce2e6fa73c55a3e2f0042cc2033a diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index 41a01c9..3004822 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -6,20 +6,16 @@ require 'yaml' module SpecHelper class Installer < Pod::Installer # Here we override the `source' of the pod specifications to point to the integration fixtures. - def dependent_specification_sets - @dependent_specification_sets ||= super - @dependent_specification_sets.each do |set| - def set.specification - spec = super - unless spec.part_of_other_pod? - source = spec.source - source[:git] = SpecHelper.fixture("integration/#{spec.name}").to_s - spec.source = source - end - spec + def dependency_specifications + @dependency_specifications ||= super + @dependency_specifications.each do |spec| + unless spec.part_of_other_pod? + source = spec.source + source[:git] = SpecHelper.fixture("integration/#{spec.name}").to_s + spec.source = source end end - @dependent_specification_sets + @dependency_specifications end end end @@ -33,7 +29,11 @@ else def create_config! Pod::Config.instance = nil - config.silent = true + if ENV['VERBOSE_SPECS'] + config.verbose = true + else + config.silent = true + end config.repos_dir = fixture('spec-repos') config.project_root = temporary_directory config.doc_install = false @@ -134,7 +134,45 @@ else change_log.should.not.include '1.3' end - if !`which appledoc`.strip.empty? + it "creates targets for different targets" do + podfile = Pod::Podfile.new do + self.platform :ios + dependency 'JSONKit', '1.4' + target :ios_target do + # This brings in Reachability on iOS + dependency 'ASIHTTPRequest' + end + target :osx_target do + self.platform :osx + dependency 'ASIHTTPRequest' + end + end + + installer = SpecHelper::Installer.new(podfile) + installer.install! + + YAML.load(installer.lock_file.read).should == { + "PODS" => [{ "ASIHTTPRequest (1.8.1)" => ["Reachability"] }, "JSONKit (1.4)", "Reachability (3.0.0)"], + "DEPENDENCIES" => ["ASIHTTPRequest", "JSONKit (= 1.4)"] + } + + with_xcodebuild_available do + Dir.chdir(config.project_pods_root) do + puts "\n[!] Compiling iOS static library..." + target_definition = podfile.target_definitions[:ios_target] + should_successfully_perform "xcodebuild -target '#{target_definition.label}'" + lib_path = config.project_pods_root + 'build/Release-iphoneos' + target_definition.lib_name + `lipo -info '#{lib_path}'`.should.include 'architecture: armv7' + + puts "\n[!] Compiling OS X static library..." + target_definition = podfile.target_definitions[:osx_target] + should_successfully_perform "xcodebuild -target '#{target_definition.label}'" + exec 'ls' + end + end + end + + if Pod::Generator::Documentation.appledoc_installed? it "generates documentation of all pods by default" do create_config! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5072ae6..8e708c4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,8 +30,9 @@ module Bacon Pod::Command::ARGV.new(argv) end + require 'colored' def xit(description, *args) - puts "\e[34m - #{description} [DISABLED]\e[0m" + puts "- #{description} [DISABLED]".blue ErrorLog << "[DISABLED] #{self.name} #{description}\n\n" end end