Commit 06008efa authored by Fabio Pelosin's avatar Fabio Pelosin

[Installer|TargetInstaller] Move code.

parent 2caeb0b4
......@@ -445,42 +445,21 @@ module Pod
# Installs the targets of the Pods projects and generates their support
# files.
#
# @todo Move the acknowledgements to the target installer?
#
def generate_target_support_files
UI.message"- Installing targets" do
target_installers.each do |target_installer|
target_installer.install!
acknowledgements_path = target_installer.library.acknowledgements_path
Generator::Acknowledgements.new(target_installer.library.target_definition,
target_installer.library.local_pods).save_as(acknowledgements_path)
generate_dummy_source(target_installer)
end
end
end
# Generates a dummy source file for each target so libraries that contain
# only categories build.
#
# @todo Move to the target installer?
#
def generate_dummy_source(target_installer)
class_name_identifier = target_installer.library.label
dummy_source = Generator::DummySource.new(class_name_identifier)
filename = "#{dummy_source.class_name}.m"
pathname = Pathname.new(sandbox.root + filename)
dummy_source.save_as(pathname)
file = pods_project.new_file(filename, "Targets Support Files")
target_installer.target.source_build_phase.add_file_reference(file)
end
# Writes the Pods project to the disk.
#
# @return [void]
#
def write_pod_project
UI.message "- Writing Xcode project file to #{UI.path @sandbox.project_path}" do
pods_project.save_as(@sandbox.project_path)
UI.message "- Writing Xcode project file to #{UI.path sandbox.project_path}" do
pods_project.save_as(sandbox.project_path)
end
end
......
......@@ -28,6 +28,8 @@ module Pod
create_prefix_header
create_bridge_support_file
create_copy_resources_script
create_acknowledgements
create_dummy_source
end
#-----------------------------------------------------------------------#
......@@ -198,6 +200,28 @@ module Pod
end
end
# Generates the acknowledgement files (markdown and plist) for the target.
#
# @return [void]
#
def create_acknowledgements
path = library.acknowledgements_path
Generator::Acknowledgements.new(target_definition, pods).save_as(path)
end
# Generates a dummy source file for each target so libraries that contain
# only categories build.
#
# @return [void]
#
def create_dummy_source
path = library.dummy_source_path
Generator::DummySource.new(library.label).save_as(path)
relative_path = path.relative_path_from(sandbox.root)
file_reference = project.new_file(relative_path, "Targets Support Files")
target.source_build_phase.add_file_reference(file_reference)
end
#-----------------------------------------------------------------------#
# @!group Private helpers.
......
......@@ -177,6 +177,12 @@ module Pod
support_files_root + "#{label}-Acknowledgements"
end
# @return [Pathname] the path of the dummy source generated by CocoaPods
#
def dummy_source_path
support_files_root + "PodsDummy_#{label}.m"
end
#-------------------------------------------------------------------------#
# @!group Private Helpers
......
......@@ -123,7 +123,7 @@ module Pod
it 'adds the source files of each pod to the target of the Pod library' do
@installer.install!
names = @installer.target.source_build_phase.files.map { |bf| bf.file_ref.name }
names.should == [ "Banana.m" ]
names.should.include("Banana.m")
end
#--------------------------------------#
......@@ -159,6 +159,24 @@ module Pod
script = config.sandbox.root + 'Pods-resources.sh'
script.read.should.include?('logo-sidebar.png')
end
it "creates the acknowledgements files " do
@installer.install!
markdown = config.sandbox.root + 'Pods-Acknowledgements.markdown'
markdown.read.should.include?('Permission is hereby granted')
plist = config.sandbox.root + 'Pods-Acknowledgements.plist'
plist.read.should.include?('Permission is hereby granted')
end
it "creates a dummy source to ensure the compilation of libraries with only categories" do
@installer.install!
build_files = @installer.target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.name == 'PodsDummy_Pods.m' }
build_file.should.be.not.nil
build_file.file_ref.path.should == 'PodsDummy_Pods.m'
dummy = config.sandbox.root + 'PodsDummy_Pods.m'
dummy.read.should.include?('@interface PodsDummy_Pods')
end
end
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