Commit b20d6402 authored by Eloy Duran's avatar Eloy Duran

Add Specification#prefix_header_contents which does not take a pch file, but a…

Add Specification#prefix_header_contents which does not take a pch file, but a string of code to be appended to the Pods pch file.
parent aed2c81a
...@@ -41,9 +41,11 @@ module Pod ...@@ -41,9 +41,11 @@ module Pod
header.puts "#import #{@target_definition.platform == :ios ? '<UIKit/UIKit.h>' : '<Cocoa/Cocoa.h>'}" header.puts "#import #{@target_definition.platform == :ios ? '<UIKit/UIKit.h>' : '<Cocoa/Cocoa.h>'}"
header.puts "#endif" header.puts "#endif"
pods.each do |pod| pods.each do |pod|
if prefix_header = pod.prefix_header_file if prefix_header_contents = pod.specification.prefix_header_contents
header.puts
header.puts prefix_header_contents
elsif prefix_header = pod.prefix_header_file
header.puts header.puts
header.puts "// Pods/#{prefix_header.relative_path_from(pod.sandbox.root)}"
header.puts prefix_header.read header.puts prefix_header.read
end end
end end
......
...@@ -98,6 +98,8 @@ module Pod ...@@ -98,6 +98,8 @@ module Pod
end end
attr_reader :prefix_header_file attr_reader :prefix_header_file
attr_accessor :prefix_header_contents
def clean_paths=(patterns) def clean_paths=(patterns)
@clean_paths = pattern_list(patterns) @clean_paths = pattern_list(patterns)
end end
......
...@@ -61,7 +61,7 @@ describe Pod::Installer::TargetInstaller do ...@@ -61,7 +61,7 @@ describe Pod::Installer::TargetInstaller do
@installer.xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc") @installer.xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc")
end end
it "creates a prefix header, including the contents of the specification's prefix header" do it "creates a prefix header, including the contents of the specification's prefix header file" do
do_install! do_install!
prefix_header = @sandbox.root + 'Pods.pch' prefix_header = @sandbox.root + 'Pods.pch'
@installer.save_prefix_header_as(prefix_header, @pods) @installer.save_prefix_header_as(prefix_header, @pods)
...@@ -70,8 +70,21 @@ describe Pod::Installer::TargetInstaller do ...@@ -70,8 +70,21 @@ describe Pod::Installer::TargetInstaller do
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#endif #endif
// Pods/BananaLib/Classes/BananaLib.pch
#import <BananaTree/BananaTree.h> #import <BananaTree/BananaTree.h>
EOS
end
it "creates a prefix header, including the contents of the specification's prefix header" do
do_install!
prefix_header = @sandbox.root + 'Pods.pch'
@specification.prefix_header_contents = '#import "BlocksKit.h"'
@installer.save_prefix_header_as(prefix_header, @pods)
prefix_header.read.should == <<-EOS
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "BlocksKit.h"
EOS EOS
end end
end end
...@@ -228,6 +228,12 @@ describe "A Pod::Specification, in general," do ...@@ -228,6 +228,12 @@ describe "A Pod::Specification, in general," do
@spec.prefix_header_file = 'Classes/Demo.pch' @spec.prefix_header_file = 'Classes/Demo.pch'
@spec.prefix_header_file.should == Pathname.new('Classes/Demo.pch') @spec.prefix_header_file.should == Pathname.new('Classes/Demo.pch')
end end
it "takes code that's to be appended to the Pods pch file" do
@spec.prefix_header_contents.should == nil
@spec.prefix_header_contents = '#import "BlocksKit.h"'
@spec.prefix_header_contents.should == '#import "BlocksKit.h"'
end
end end
describe "A Pod::Specification subspec" do describe "A Pod::Specification subspec" do
......
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