Commit 38d85b09 authored by siuying's avatar siuying

Merge pull request #232 from siuying/dummy_source

Add dummy source file to Pod project
parents 19a75192 cdee5f90
...@@ -30,6 +30,7 @@ module Pod ...@@ -30,6 +30,7 @@ module Pod
autoload :BridgeSupport, 'cocoapods/generator/bridge_support' autoload :BridgeSupport, 'cocoapods/generator/bridge_support'
autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script' autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script'
autoload :Documentation, 'cocoapods/generator/documentation' autoload :Documentation, 'cocoapods/generator/documentation'
autoload :DummySource, 'cocoapods/generator/dummy_source'
end end
end end
......
module Pod
module Generator
class DummySource
def initialize(label="Pods")
@label = label.gsub(/[^a-zA-Z]/, '')
end
def save_as(pathname)
pathname.open('w') do |source|
source.puts "@interface #{@label}Dummy : NSObject"
source.puts "@end"
source.puts "@implementation #{@label}Dummy"
source.puts "@end"
end
end
end
end
end
...@@ -53,7 +53,7 @@ module Pod ...@@ -53,7 +53,7 @@ module Pod
end end
def target_support_files def target_support_files
[:copy_resources_script_name, :prefix_header_name, :xcconfig_name].map { |file| @target_definition.send(file) } [:copy_resources_script_name, :prefix_header_name, :xcconfig_name, :dummy_source_name].map { |file| @target_definition.send(file) }
end end
# TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support. # TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
...@@ -77,9 +77,9 @@ module Pod ...@@ -77,9 +77,9 @@ module Pod
support_files_group.create_files(target_support_files) support_files_group.create_files(target_support_files)
xcconfig_file = support_files_group.files.where(:path => @target_definition.xcconfig_name) xcconfig_file = support_files_group.files.where(:path => @target_definition.xcconfig_name)
configure_build_configurations(xcconfig_file) configure_build_configurations(xcconfig_file)
create_files(pods, sandbox) create_files(pods, sandbox)
add_dummy_file(support_files_group)
end end
def configure_build_configurations(xcconfig_file) def configure_build_configurations(xcconfig_file)
...@@ -91,6 +91,11 @@ module Pod ...@@ -91,6 +91,11 @@ module Pod
end end
end end
def add_dummy_file(support_files_group)
dummy = Pathname.new(@target_definition.dummy_source_name)
@target.add_source_file(dummy)
end
def create_files(pods, sandbox) def create_files(pods, sandbox)
if @podfile.generate_bridge_support? if @podfile.generate_bridge_support?
bridge_support_metadata_path = sandbox.root + @target_definition.bridge_support_name bridge_support_metadata_path = sandbox.root + @target_definition.bridge_support_name
...@@ -104,6 +109,8 @@ module Pod ...@@ -104,6 +109,8 @@ module Pod
save_prefix_header_as(sandbox.root + @target_definition.prefix_header_name, pods) save_prefix_header_as(sandbox.root + @target_definition.prefix_header_name, pods)
puts "* Generating copy resources script at `#{sandbox.root + @target_definition.copy_resources_script_name}'" if config.verbose? puts "* Generating copy resources script at `#{sandbox.root + @target_definition.copy_resources_script_name}'" if config.verbose?
copy_resources_script_for(pods).save_as(sandbox.root + @target_definition.copy_resources_script_name) copy_resources_script_for(pods).save_as(sandbox.root + @target_definition.copy_resources_script_name)
puts "* Generating dummy source at `#{sandbox.root + @target_definition.dummy_source_name}'" if config.verbose?
Generator::DummySource.new(@target_definition.label).save_as(sandbox.root + @target_definition.dummy_source_name)
end end
private private
......
...@@ -96,6 +96,10 @@ module Pod ...@@ -96,6 +96,10 @@ module Pod
"#{label}-prefix.pch" "#{label}-prefix.pch"
end end
def dummy_source_name
"#{label}Dummy.m"
end
def bridge_support_name def bridge_support_name
"#{label}.bridgesupport" "#{label}.bridgesupport"
end end
......
...@@ -119,6 +119,26 @@ else ...@@ -119,6 +119,26 @@ else
} }
end end
it "install a dummy source file" do
create_config!
podfile = Pod::Podfile.new do
self.platform :ios
xcodeproj 'dummy'
dependency do |s|
s.name = 'JSONKit'
s.version = '1.2'
s.source = { :git => SpecHelper.fixture('integration/JSONKit').to_s, :tag => 'v1.2' }
s.source_files = 'JSONKit.*'
end
end
installer = SpecHelper::Installer.new(podfile)
installer.install!
dummy = (config.project_pods_root + 'PodsDummy.m').read
dummy.should.include?('@implementation PodsDummy')
end
it "installs a library with a podspec defined inline" do it "installs a library with a podspec defined inline" do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform :ios self.platform :ios
......
require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Generator::DummySource do
extend SpecHelper::TemporaryDirectory
before do
setup_temporary_directory
end
after do
teardown_temporary_directory
end
it "generates a dummy sourcefile with the appropriate class" do
generator = Pod::Generator::DummySource.new("Pods")
file = temporary_directory + 'PodsDummy.m'
generator.save_as(file)
file.read.should == <<-EOS
@interface PodsDummy : NSObject
@end
@implementation PodsDummy
@end
EOS
end
end
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