From 853089742f1e3e86dd4baa8d4506dc2ac07df4e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 9 May 2012 14:30:03 +0200 Subject: [PATCH 1/5] [#221] Pod::Spec#public_header_files accepted and validated by `pod spec lint` --- lib/cocoapods/command/spec.rb | 17 ++++++++++++++++- lib/cocoapods/file_list.rb | 2 +- lib/cocoapods/specification.rb | 11 +++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/cocoapods/command/spec.rb b/lib/cocoapods/command/spec.rb index d38ca30e21..a281da1efd 100644 --- a/lib/cocoapods/command/spec.rb +++ b/lib/cocoapods/command/spec.rb @@ -298,7 +298,7 @@ def names_match? def paths_starting_with_a_slash_errors messages = [] - %w[source_files resources clean_paths].each do |accessor| + %w[source_files public_header_files resources clean_paths].each do |accessor| patterns = spec.send(accessor.to_sym) # Some values are multiplaform patterns = patterns.is_a?(Hash) ? patterns.values.flatten(1) : patterns @@ -400,6 +400,10 @@ def file_patterns_errors # at least one file. It requires the pods to be alredy present # in the current working directory under Pods/spec.name # + # The exceptions are public_header_files and clean_paths, + # since a Spec may declare an explicit empty list of public + # header files, and an explicit empty of paths to be cleaned up. + # # It returns a array of messages # def file_patterns_errors_for_platfrom(platform_name) @@ -535,6 +539,17 @@ def spec_template(data) s.description = 'An optional longer description of #{data[:name]}.' + # A list of file patterns which select the header files that should be + # made available to the application. If the pattern is a directory then the + # path will automatically have '*.h' appended. + # + # Also allows the use of the FileList class like `source_files does. + # + # If you do not explicitely set the list of public header files, + # all headers of source_files will be made public. + # + # s.public_header_files = 'Classes/**/*.h' + # If this Pod runs only on iOS or OS X, then specify the platform and # the deployment target. # diff --git a/lib/cocoapods/file_list.rb b/lib/cocoapods/file_list.rb index 863bc90c93..a37b643324 100644 --- a/lib/cocoapods/file_list.rb +++ b/lib/cocoapods/file_list.rb @@ -5,7 +5,7 @@ end # This makes Rake::FileList usable with the Specification attributes -# source_files, clean_paths, and resources. +# source_files, public_header_files, clean_paths, and resources. module Rake class FileList diff --git a/lib/cocoapods/specification.rb b/lib/cocoapods/specification.rb index b15acbf64e..c006f0b693 100644 --- a/lib/cocoapods/specification.rb +++ b/lib/cocoapods/specification.rb @@ -33,7 +33,7 @@ def initialize def post_initialize @define_for_platforms = [:osx, :ios] @clean_paths, @subspecs = [], [] - @dependencies, @source_files, @resources = { :ios => [], :osx => [] }, { :ios => [], :osx => [] }, { :ios => [], :osx => [] } + @dependencies, @source_files, @public_header_files, @resources = { :ios => [], :osx => [] }, { :ios => [], :osx => [] }, { :ios => nil, :osx => nil }, { :ios => [], :osx => [] } @deployment_target = {} @platform = Platform.new(nil) @xcconfig = { :ios => Xcodeproj::Config.new, :osx => Xcodeproj::Config.new } @@ -155,7 +155,7 @@ def initialize(specification, platform) @specification, @platform = specification, platform end - %w{ source_files= resource= resources= xcconfig= framework= frameworks= library= libraries= compiler_flags= deployment_target= dependency }.each do |method| + %w{ source_files= public_header_files= resource= resources= xcconfig= framework= frameworks= library= libraries= compiler_flags= deployment_target= dependency }.each do |method| define_method(method) do |args| @specification._on_platform(@platform) do @specification.send(method, args) @@ -179,6 +179,13 @@ def source_files=(patterns) end attr_reader :source_files + def public_header_files=(patterns) + @define_for_platforms.each do |platform| + @public_header_files[platform] = pattern_list(patterns) + end + end + attr_reader :public_header_files + def deployment_target=(version) raise Informative, "The deployment target must be defined per platform like s.ios.deployment_target = '5.0'" unless @define_for_platforms.count == 1 @deployment_target[@define_for_platforms.first] = version From 3f9aa83790b2dbe3448d420ef4d0f7d36f927464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 10 May 2012 14:49:03 +0200 Subject: [PATCH 2/5] [#221] Pod::Sandbox#build_header_storage and Pod::Sandbox#public_header_storage Those methods return Pod::HeaderStorage instances, managing respectively build headers and public headers. Those objects replace and encapsulate former Pod::Sandbox#headers_root, add_header_file, add_header_files and header_search_paths methods. For instance, instead of sandbox.header_search_paths, write sandbox.build_header_storage.search_paths. --- lib/cocoapods/installer/target_installer.rb | 2 +- lib/cocoapods/local_pod.rb | 23 ++++++- lib/cocoapods/sandbox.rb | 65 ++++++++++++-------- spec/functional/command/spec_spec.rb | 1 + spec/unit/installer/target_installer_spec.rb | 2 +- spec/unit/local_pod_spec.rb | 6 +- spec/unit/sandbox_spec.rb | 10 +-- 7 files changed, 74 insertions(+), 35 deletions(-) diff --git a/lib/cocoapods/installer/target_installer.rb b/lib/cocoapods/installer/target_installer.rb index 378057d406..6b4ed6412e 100644 --- a/lib/cocoapods/installer/target_installer.rb +++ b/lib/cocoapods/installer/target_installer.rb @@ -71,7 +71,7 @@ def install!(pods, sandbox) pod.link_headers end - xcconfig.merge!('HEADER_SEARCH_PATHS' => quoted(sandbox.header_search_paths).join(" ")) + xcconfig.merge!('HEADER_SEARCH_PATHS' => quoted(sandbox.build_header_storage.search_paths).join(" ")) support_files_group = @project.group("Targets Support Files").create_group(@target_definition.label) support_files_group.create_files(target_support_files) diff --git a/lib/cocoapods/local_pod.rb b/lib/cocoapods/local_pod.rb index 7897ac63b5..9374dc9b8f 100644 --- a/lib/cocoapods/local_pod.rb +++ b/lib/cocoapods/local_pod.rb @@ -75,9 +75,20 @@ def header_files source_files.select { |f| f.extname == '.h' } end + def public_header_files + if specification.public_header_files[@platform.name] + expanded_paths(specification.public_header_files, :glob => '*.h', :relative_to_sandbox => true) + else + header_files + end + end + def link_headers copy_header_mappings.each do |namespaced_path, files| - @sandbox.add_header_files(namespaced_path, files) + @sandbox.build_header_storage.add_files(namespaced_path, files) + end + copy_public_header_mappings.each do |namespaced_path, files| + @sandbox.public_header_storage.add_files(namespaced_path, files) end end @@ -116,6 +127,16 @@ def copy_header_mappings end end + # TODO comment about copy_header_mappings may well apply to this method as well + def copy_public_header_mappings + public_header_files.inject({}) do |mappings, from| + from_without_prefix = from.relative_path_from(relative_root) + to = specification.header_dir + specification.copy_header_mapping(from_without_prefix) + (mappings[to.dirname] ||= []) << from + mappings + end + end + def expanded_paths(platforms_with_patterns, options = {}) patterns = platforms_with_patterns.is_a?(Hash) ? platforms_with_patterns[@platform.name] : platforms_with_patterns patterns.map do |pattern| diff --git a/lib/cocoapods/sandbox.rb b/lib/cocoapods/sandbox.rb index 10f8e3a71a..27fda0ed84 100644 --- a/lib/cocoapods/sandbox.rb +++ b/lib/cocoapods/sandbox.rb @@ -3,12 +3,16 @@ module Pod class Sandbox attr_reader :root + attr_reader :build_header_storage + attr_reader :public_header_storage - HEADERS_DIR = "Headers" + PUBLIC_HEADERS_DIR = "Headers" + BUILD_HEADERS_DIR = "BuildHeaders" def initialize(path) @root = Pathname.new(path) - @header_search_paths = [HEADERS_DIR] + @build_header_storage = HeaderStorage.new(self, BUILD_HEADERS_DIR) + @public_header_storage = HeaderStorage.new(self, PUBLIC_HEADERS_DIR) FileUtils.mkdir_p(@root) end @@ -17,33 +21,13 @@ def implode root.rmtree end - def headers_root - root + HEADERS_DIR - end - def project_path root + "Pods.xcodeproj" end - def add_header_file(namespace_path, relative_header_path) - namespaced_header_path = headers_root + namespace_path - namespaced_header_path.mkpath unless File.exist?(namespaced_header_path) - source = (root + relative_header_path).relative_path_from(namespaced_header_path) - Dir.chdir(namespaced_header_path) { FileUtils.ln_sf(source, relative_header_path.basename)} - @header_search_paths << namespaced_header_path.relative_path_from(root) - namespaced_header_path + relative_header_path.basename - end - - def add_header_files(namespace_path, relative_header_paths) - relative_header_paths.map { |path| add_header_file(namespace_path, path) } - end - - def header_search_paths - @header_search_paths.uniq.map { |path| "${PODS_ROOT}/#{path}" } - end - def prepare_for_install - headers_root.rmtree if headers_root.exist? + build_header_storage.prepare_for_install + public_header_storage.prepare_for_install end def podspec_for_name(name) @@ -60,4 +44,37 @@ def installed_pod_named(name, platform) end end end + + class HeaderStorage + def initialize(sandbox, base_dir) + @sandbox = sandbox + @base_dir = base_dir + @search_paths = [base_dir] + end + + def root + @sandbox.root + @base_dir + end + + def add_file(namespace_path, relative_header_path) + namespaced_header_path = @sandbox.root + @base_dir + namespace_path + namespaced_header_path.mkpath unless File.exist?(namespaced_header_path) + source = (@sandbox.root + relative_header_path).relative_path_from(namespaced_header_path) + Dir.chdir(namespaced_header_path) { FileUtils.ln_sf(source, relative_header_path.basename)} + @search_paths << namespaced_header_path.relative_path_from(@sandbox.root) + namespaced_header_path + relative_header_path.basename + end + + def add_files(namespace_path, relative_header_paths) + relative_header_paths.map { |path| add_file(namespace_path, path) } + end + + def search_paths + @search_paths.uniq.map { |path| "${PODS_ROOT}/#{path}" } + end + + def prepare_for_install + root.rmtree if root.exist? + end + end end diff --git a/spec/functional/command/spec_spec.rb b/spec/functional/command/spec_spec.rb index 3375e81812..4eb8e40c8f 100644 --- a/spec/functional/command/spec_spec.rb +++ b/spec/functional/command/spec_spec.rb @@ -33,6 +33,7 @@ spec.source.should == { :git => 'http://EXAMPLE/Bananas.git', :tag => '0.0.1' } spec.description.should == 'An optional longer description of Bananas.' spec.source_files[:ios].should == ['Classes', 'Classes/**/*.{h,m}'] + spec.public_header_files[:ios].should == nil end it "correctly creates a podspec from github" do diff --git a/spec/unit/installer/target_installer_spec.rb b/spec/unit/installer/target_installer_spec.rb index 5bec40a04c..131bd93bf1 100644 --- a/spec/unit/installer/target_installer_spec.rb +++ b/spec/unit/installer/target_installer_spec.rb @@ -51,7 +51,7 @@ def do_install! it 'adds the sandbox header search paths to the xcconfig, with quotes' do do_install! - @installer.xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include("\"#{@sandbox.header_search_paths.join('" "')}\"") + @installer.xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include("\"#{@sandbox.build_header_storage.search_paths.join('" "')}\"") end it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do diff --git a/spec/unit/local_pod_spec.rb b/spec/unit/local_pod_spec.rb index c58c662bc0..ea7bc6c8a0 100644 --- a/spec/unit/local_pod_spec.rb +++ b/spec/unit/local_pod_spec.rb @@ -61,7 +61,7 @@ it "can link it's headers into the sandbox" do @pod.link_headers - expected_header_path = @sandbox.headers_root + "BananaLib/Banana.h" + expected_header_path = @sandbox.build_header_storage.root + "BananaLib/Banana.h" expected_header_path.should.be.symlink File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read end @@ -147,7 +147,7 @@ def @spec.copy_header_mapping(from) def @spec.copy_header_mapping(from) Pathname.new('ns') + from.basename end - @spec.header_search_paths.should == %w{ + @spec.build_header_storage.search_paths.should == %w{ "$(PODS_ROOT)/Headers/SSZipArchive" "$(PODS_ROOT)/Headers/SSZipArchive/ns" } @@ -158,7 +158,7 @@ def @spec.copy_header_mapping(from) def @spec.copy_header_mapping(from) Pathname.new('ns') + from.basename end - @spec.header_search_paths.should == %w{ + @spec.build_header_storage.search_paths.should == %w{ "$(PODS_ROOT)/Headers/AnotherRoot" "$(PODS_ROOT)/Headers/AnotherRoot/ns" } diff --git a/spec/unit/sandbox_spec.rb b/spec/unit/sandbox_spec.rb index 14e4af942a..812a3146f8 100644 --- a/spec/unit/sandbox_spec.rb +++ b/spec/unit/sandbox_spec.rb @@ -24,7 +24,7 @@ end it "returns it's headers root" do - @sandbox.headers_root.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers")) + @sandbox.build_header_storage.root.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers")) end it "can add namespaced headers to it's header path using symlinks and return the relative path" do @@ -32,7 +32,7 @@ namespace_path = Pathname.new("ExampleLib") relative_header_path = Pathname.new("ExampleLib/Headers/MyHeader.h") File.open(@sandbox.root + relative_header_path, "w") { |file| file.write('hello') } - symlink_path = @sandbox.add_header_file(namespace_path, relative_header_path) + symlink_path = @sandbox.build_header_storage.add_file(namespace_path, relative_header_path) symlink_path.should.be.symlink File.read(symlink_path).should == 'hello' end @@ -47,7 +47,7 @@ relative_header_paths.each do |path| File.open(@sandbox.root + path, "w") { |file| file.write('hello') } end - symlink_paths = @sandbox.add_header_files(namespace_path, relative_header_paths) + symlink_paths = @sandbox.build_header_storage.add_files(namespace_path, relative_header_paths) symlink_paths.each do |path| path.should.be.symlink File.read(path).should == "hello" @@ -64,7 +64,7 @@ relative_header_paths.each do |path| File.open(@sandbox.root + path, "w") { |file| file.write('hello') } end - @sandbox.add_header_files(namespace_path, relative_header_paths) + @sandbox.build_header_storage.add_files(namespace_path, relative_header_paths) @sandbox.header_search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib") end @@ -74,6 +74,6 @@ it 'clears out its headers root when preparing for install' do @sandbox.prepare_for_install - @sandbox.headers_root.should.not.exist + @sandbox.build_header_storage.root.should.not.exist end end From 5a2c29c06663aa10b7881b606271460fd872069e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 11 May 2012 14:02:36 +0200 Subject: [PATCH 3/5] [#221] HEADER_SEARCH_PATHS value comes from the new variable PODS_HEADER_SEARCH_PATHS. PODS_HEADER_SEARCH_PATHS is set to public headers search paths in Pods.xcconfig, and to build headers search paths in Pods.xcodeproj. --- lib/cocoapods/installer/target_installer.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/cocoapods/installer/target_installer.rb b/lib/cocoapods/installer/target_installer.rb index 6b4ed6412e..774236e48a 100644 --- a/lib/cocoapods/installer/target_installer.rb +++ b/lib/cocoapods/installer/target_installer.rb @@ -71,22 +71,25 @@ def install!(pods, sandbox) pod.link_headers end - xcconfig.merge!('HEADER_SEARCH_PATHS' => quoted(sandbox.build_header_storage.search_paths).join(" ")) - + # Indirect HEADER_SEARCH_PATHS, so that configure_build_configurations can override it + xcconfig.merge!('HEADER_SEARCH_PATHS' => '${PODS_HEADER_SEARCH_PATHS}') + xcconfig.merge!('PODS_HEADER_SEARCH_PATHS' => quoted(sandbox.public_header_storage.search_paths).join(" ")) + support_files_group = @project.group("Targets Support Files").create_group(@target_definition.label) support_files_group.create_files(target_support_files) xcconfig_file = support_files_group.files.where(:path => @target_definition.xcconfig_name) - configure_build_configurations(xcconfig_file) + configure_build_configurations(xcconfig_file, sandbox) create_files(pods, sandbox) end - def configure_build_configurations(xcconfig_file) + def configure_build_configurations(xcconfig_file, sandbox) @target.build_configurations.each do |config| config.base_configuration = xcconfig_file config.build_settings['OTHER_LDFLAGS'] = '' config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name config.build_settings['PODS_ROOT'] = '${SRCROOT}' + config.build_settings['PODS_HEADER_SEARCH_PATHS'] = quoted(sandbox.build_header_storage.search_paths).join(" ") end end From 0aea0befa45002f439d8938fb84504e0e2277236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 11 May 2012 14:07:31 +0200 Subject: [PATCH 4/5] [#221] code cleanup --- lib/cocoapods/installer/target_installer.rb | 4 +-- lib/cocoapods/local_pod.rb | 4 +-- lib/cocoapods/sandbox.rb | 31 ++++++++++---------- spec/unit/installer/target_installer_spec.rb | 2 +- spec/unit/local_pod_spec.rb | 6 ++-- spec/unit/sandbox_spec.rb | 10 +++---- 6 files changed, 28 insertions(+), 29 deletions(-) diff --git a/lib/cocoapods/installer/target_installer.rb b/lib/cocoapods/installer/target_installer.rb index 774236e48a..c6dcf6d701 100644 --- a/lib/cocoapods/installer/target_installer.rb +++ b/lib/cocoapods/installer/target_installer.rb @@ -73,7 +73,7 @@ def install!(pods, sandbox) # Indirect HEADER_SEARCH_PATHS, so that configure_build_configurations can override it xcconfig.merge!('HEADER_SEARCH_PATHS' => '${PODS_HEADER_SEARCH_PATHS}') - xcconfig.merge!('PODS_HEADER_SEARCH_PATHS' => quoted(sandbox.public_header_storage.search_paths).join(" ")) + xcconfig.merge!('PODS_HEADER_SEARCH_PATHS' => quoted(sandbox.public_headers.search_paths).join(" ")) support_files_group = @project.group("Targets Support Files").create_group(@target_definition.label) support_files_group.create_files(target_support_files) @@ -89,7 +89,7 @@ def configure_build_configurations(xcconfig_file, sandbox) config.build_settings['OTHER_LDFLAGS'] = '' config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name config.build_settings['PODS_ROOT'] = '${SRCROOT}' - config.build_settings['PODS_HEADER_SEARCH_PATHS'] = quoted(sandbox.build_header_storage.search_paths).join(" ") + config.build_settings['PODS_HEADER_SEARCH_PATHS'] = quoted(sandbox.build_headers.search_paths).join(" ") end end diff --git a/lib/cocoapods/local_pod.rb b/lib/cocoapods/local_pod.rb index 9374dc9b8f..1027caeb51 100644 --- a/lib/cocoapods/local_pod.rb +++ b/lib/cocoapods/local_pod.rb @@ -85,10 +85,10 @@ def public_header_files def link_headers copy_header_mappings.each do |namespaced_path, files| - @sandbox.build_header_storage.add_files(namespaced_path, files) + @sandbox.build_headers.add_files(namespaced_path, files) end copy_public_header_mappings.each do |namespaced_path, files| - @sandbox.public_header_storage.add_files(namespaced_path, files) + @sandbox.public_headers.add_files(namespaced_path, files) end end diff --git a/lib/cocoapods/sandbox.rb b/lib/cocoapods/sandbox.rb index 27fda0ed84..6e918691ed 100644 --- a/lib/cocoapods/sandbox.rb +++ b/lib/cocoapods/sandbox.rb @@ -3,17 +3,16 @@ module Pod class Sandbox attr_reader :root - attr_reader :build_header_storage - attr_reader :public_header_storage + attr_reader :build_headers + attr_reader :public_headers - PUBLIC_HEADERS_DIR = "Headers" BUILD_HEADERS_DIR = "BuildHeaders" + PUBLIC_HEADERS_DIR = "Headers" def initialize(path) @root = Pathname.new(path) - @build_header_storage = HeaderStorage.new(self, BUILD_HEADERS_DIR) - @public_header_storage = HeaderStorage.new(self, PUBLIC_HEADERS_DIR) - + @build_headers = HeadersDirectory.new(self, BUILD_HEADERS_DIR) + @public_headers = HeadersDirectory.new(self, PUBLIC_HEADERS_DIR) FileUtils.mkdir_p(@root) end @@ -26,8 +25,8 @@ def project_path end def prepare_for_install - build_header_storage.prepare_for_install - public_header_storage.prepare_for_install + build_headers.prepare_for_install + public_headers.prepare_for_install end def podspec_for_name(name) @@ -44,35 +43,35 @@ def installed_pod_named(name, platform) end end end - - class HeaderStorage + + class HeadersDirectory def initialize(sandbox, base_dir) @sandbox = sandbox @base_dir = base_dir @search_paths = [base_dir] end - + def root @sandbox.root + @base_dir end - + def add_file(namespace_path, relative_header_path) - namespaced_header_path = @sandbox.root + @base_dir + namespace_path + namespaced_header_path = root + namespace_path namespaced_header_path.mkpath unless File.exist?(namespaced_header_path) source = (@sandbox.root + relative_header_path).relative_path_from(namespaced_header_path) Dir.chdir(namespaced_header_path) { FileUtils.ln_sf(source, relative_header_path.basename)} @search_paths << namespaced_header_path.relative_path_from(@sandbox.root) namespaced_header_path + relative_header_path.basename end - + def add_files(namespace_path, relative_header_paths) relative_header_paths.map { |path| add_file(namespace_path, path) } end - + def search_paths @search_paths.uniq.map { |path| "${PODS_ROOT}/#{path}" } end - + def prepare_for_install root.rmtree if root.exist? end diff --git a/spec/unit/installer/target_installer_spec.rb b/spec/unit/installer/target_installer_spec.rb index 131bd93bf1..583e6665a7 100644 --- a/spec/unit/installer/target_installer_spec.rb +++ b/spec/unit/installer/target_installer_spec.rb @@ -51,7 +51,7 @@ def do_install! it 'adds the sandbox header search paths to the xcconfig, with quotes' do do_install! - @installer.xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include("\"#{@sandbox.build_header_storage.search_paths.join('" "')}\"") + @installer.xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include("\"#{@sandbox.build_headers.search_paths.join('" "')}\"") end it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do diff --git a/spec/unit/local_pod_spec.rb b/spec/unit/local_pod_spec.rb index ea7bc6c8a0..cbdfae13a3 100644 --- a/spec/unit/local_pod_spec.rb +++ b/spec/unit/local_pod_spec.rb @@ -61,7 +61,7 @@ it "can link it's headers into the sandbox" do @pod.link_headers - expected_header_path = @sandbox.build_header_storage.root + "BananaLib/Banana.h" + expected_header_path = @sandbox.build_headers.root + "BananaLib/Banana.h" expected_header_path.should.be.symlink File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read end @@ -147,7 +147,7 @@ def @spec.copy_header_mapping(from) def @spec.copy_header_mapping(from) Pathname.new('ns') + from.basename end - @spec.build_header_storage.search_paths.should == %w{ + @spec.build_headers.search_paths.should == %w{ "$(PODS_ROOT)/Headers/SSZipArchive" "$(PODS_ROOT)/Headers/SSZipArchive/ns" } @@ -158,7 +158,7 @@ def @spec.copy_header_mapping(from) def @spec.copy_header_mapping(from) Pathname.new('ns') + from.basename end - @spec.build_header_storage.search_paths.should == %w{ + @spec.build_headers.search_paths.should == %w{ "$(PODS_ROOT)/Headers/AnotherRoot" "$(PODS_ROOT)/Headers/AnotherRoot/ns" } diff --git a/spec/unit/sandbox_spec.rb b/spec/unit/sandbox_spec.rb index 812a3146f8..0c8f926909 100644 --- a/spec/unit/sandbox_spec.rb +++ b/spec/unit/sandbox_spec.rb @@ -24,7 +24,7 @@ end it "returns it's headers root" do - @sandbox.build_header_storage.root.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers")) + @sandbox.build_headers.root.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers")) end it "can add namespaced headers to it's header path using symlinks and return the relative path" do @@ -32,7 +32,7 @@ namespace_path = Pathname.new("ExampleLib") relative_header_path = Pathname.new("ExampleLib/Headers/MyHeader.h") File.open(@sandbox.root + relative_header_path, "w") { |file| file.write('hello') } - symlink_path = @sandbox.build_header_storage.add_file(namespace_path, relative_header_path) + symlink_path = @sandbox.build_headers.add_file(namespace_path, relative_header_path) symlink_path.should.be.symlink File.read(symlink_path).should == 'hello' end @@ -47,7 +47,7 @@ relative_header_paths.each do |path| File.open(@sandbox.root + path, "w") { |file| file.write('hello') } end - symlink_paths = @sandbox.build_header_storage.add_files(namespace_path, relative_header_paths) + symlink_paths = @sandbox.build_headers.add_files(namespace_path, relative_header_paths) symlink_paths.each do |path| path.should.be.symlink File.read(path).should == "hello" @@ -64,7 +64,7 @@ relative_header_paths.each do |path| File.open(@sandbox.root + path, "w") { |file| file.write('hello') } end - @sandbox.build_header_storage.add_files(namespace_path, relative_header_paths) + @sandbox.build_headers.add_files(namespace_path, relative_header_paths) @sandbox.header_search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib") end @@ -74,6 +74,6 @@ it 'clears out its headers root when preparing for install' do @sandbox.prepare_for_install - @sandbox.build_header_storage.root.should.not.exist + @sandbox.build_headers.root.should.not.exist end end From be2756928a204c640a5bf8e55f7a1d27661c1322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 11 May 2012 14:24:34 +0200 Subject: [PATCH 5/5] [#221] robustness against nil file lists (such as public_header_files) --- lib/cocoapods/command/spec.rb | 1 + lib/cocoapods/local_pod.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/cocoapods/command/spec.rb b/lib/cocoapods/command/spec.rb index a281da1efd..d3b5ff9da0 100644 --- a/lib/cocoapods/command/spec.rb +++ b/lib/cocoapods/command/spec.rb @@ -302,6 +302,7 @@ def paths_starting_with_a_slash_errors patterns = spec.send(accessor.to_sym) # Some values are multiplaform patterns = patterns.is_a?(Hash) ? patterns.values.flatten(1) : patterns + patterns = patterns.compact # some patterns may be nil (public_header_files, for instance) patterns.each do |pattern| # Skip Filelist that would otherwise be resolved from the working directory resulting # in a potentially very expensi operation diff --git a/lib/cocoapods/local_pod.rb b/lib/cocoapods/local_pod.rb index 1027caeb51..25f5964456 100644 --- a/lib/cocoapods/local_pod.rb +++ b/lib/cocoapods/local_pod.rb @@ -139,6 +139,7 @@ def copy_public_header_mappings def expanded_paths(platforms_with_patterns, options = {}) patterns = platforms_with_patterns.is_a?(Hash) ? platforms_with_patterns[@platform.name] : platforms_with_patterns + return [] if patterns.nil? # some patterns may be nil (specification.public_header_files, for instance) patterns.map do |pattern| pattern = root + pattern