Commit 8390e00b authored by Luke Redpath's avatar Luke Redpath

Encapsulate adding a pod's source files to an Xcode target within LocalPod.

parent ef25e3f1
......@@ -7,5 +7,5 @@ group :development do
gem "guard-bacon"
gem "rb-fsevent"
gem "growl"
gem "mocha"
gem "mocha-on-bacon"
end
......@@ -11,6 +11,8 @@ GEM
metaclass (0.0.1)
mocha (0.10.4)
metaclass (~> 0.0.1)
mocha-on-bacon (0.2.0)
mocha (>= 0.9.8)
rake (0.9.2.2)
rb-fsevent (0.9.0)
schmurfy-bacon (1.2.1)
......@@ -26,6 +28,6 @@ DEPENDENCIES
growl
guard
guard-bacon
mocha
mocha-on-bacon
rake
rb-fsevent
......@@ -66,11 +66,7 @@ module Pod
pods.each do |pod|
xcconfig.merge!(pod.specification.xcconfig)
pod.implementation_files.each do |file|
@target.add_source_file(file, nil, pod.specification.compiler_flags)
end
pod.add_to_target(@target)
pod.link_headers
end
......
......@@ -50,10 +50,6 @@ module Pod
def resources
expanded_paths(specification.resources, :relative_to_sandbox => true)
end
def implementation_files
source_files.select { |f| f.extname != '.h' }
end
def header_files
source_files.select { |f| f.extname == '.h' }
......@@ -65,8 +61,18 @@ module Pod
end
end
def add_to_target(target)
implementation_files.each do |file|
target.add_source_file(file, nil, specification.compiler_flags)
end
end
private
def implementation_files
source_files.select { |f| f.extname != '.h' }
end
def relative_root
root.relative_path_from(@sandbox.root)
end
......
......@@ -121,8 +121,8 @@ module Pod
attr_writer :compiler_flags
def compiler_flags
flags = "#{@compiler_flags} "
flags << '-fobjc-arc' if requires_arc
flags = "#{@compiler_flags}"
flags << ' -fobjc-arc' if requires_arc
flags
end
......@@ -265,10 +265,6 @@ module Pod
files
end
def implementation_files
expanded_source_files.select { |f| f.extname != '.h' }
end
# Returns only the header files of this pod.
def header_files
expanded_source_files.select { |f| f.extname == '.h' }
......
require 'rubygems'
require 'bacon'
require 'mocha'
require 'mocha-on-bacon'
require 'pathname'
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
......
......@@ -45,10 +45,6 @@ describe Pod::LocalPod do
@pod.resources.should == [Pathname.new("BananaLib/Resources/logo-sidebar.png")]
end
it 'returns a list of implementation files' do
@pod.implementation_files.should == [Pathname.new("BananaLib/Classes/Banana.m")]
end
it 'returns a list of header files' do
@pod.header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")]
end
......@@ -70,4 +66,17 @@ describe Pod::LocalPod do
File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read
end
it "can add it's source files to an Xcode project target" do
target = mock('target')
target.expects(:add_source_file).with(Pathname.new("BananaLib/Classes/Banana.m"), anything, anything)
@pod.add_to_target(target)
end
it "can add it's source files to a target with any specially configured compiler flags" do
@pod.specification.compiler_flags = '-d some_flag'
target = mock('target')
target.expects(:add_source_file).with(anything, anything, "-d some_flag")
@pod.add_to_target(target)
end
end
......@@ -160,12 +160,6 @@ describe "A Pod::Specification, with installed source," do
@spec.header_files.sort.should == files.sort
end
it "returns the list of implementation files" do
files = @destroot.glob('**/*.{c,m}')
files = files.map { |file| file.relative_path_from(config.project_pods_root) }
@spec.implementation_files.sort.should == files.sort
end
it "returns a hash of mappings from the pod's destroot to its header dirs, which by default is just the pod's header dir" do
@spec.copy_header_mappings.size.should == 1
@spec.copy_header_mappings[Pathname.new('SSZipArchive')].sort.should == %w{
......
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