Raise an exception if unable to find a reference for a path and handle symlink references

parent 9033df9d
......@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes
* Raise an exception if unable to find a reference for a path and handle symlink references.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#5427](https://github.com/CocoaPods/CocoaPods/issues/5427)
* Re-escaped backslashes in embed_frameworks generator
[Harlan Haskins](https://github.com/harlanhaskins)
[#6121](https://github.com/CocoaPods/CocoaPods/issues/6121)
......
......@@ -97,11 +97,11 @@ module Pod
}.each do |arc, files|
files = files - headers - other_source_files
flags = compiler_flags_for_consumer(consumer, arc)
regular_file_refs = files.map { |sf| project.reference_for_path(sf) }
regular_file_refs = project_file_references_array(files, 'source')
native_target.add_file_references(regular_file_refs, flags)
end
header_file_refs = headers.map { |sf| project.reference_for_path(sf) }
header_file_refs = project_file_references_array(headers, 'header')
native_target.add_file_references(header_file_refs) do |build_file|
add_header(build_file, public_headers, private_headers)
end
......@@ -360,6 +360,14 @@ module Pod
@custom_module_map ||= target.file_accessors.first.module_map
end
def project_file_references_array(files, file_type)
files.map do |sf|
project.reference_for_path(sf).tap do |ref|
raise Informative, "Unable to find #{file_type} ref for #{sf} for target #{target.name}." unless ref
end
end
end
def header_mappings_dir
return @header_mappings_dir if defined?(@header_mappings_dir)
file_accessor = target.file_accessors.first
......
......@@ -184,6 +184,7 @@ module Pod
group = group_for_path_in_group(file_path_name, group, reflect_file_system_structure)
if ref = reference_for_path(file_path_name.realpath)
@refs_by_absolute_path[absolute_path.to_s] = ref
ref
else
ref = group.new_file(file_path_name.realpath)
......
......@@ -147,6 +147,61 @@ module Pod
names.should.include('Banana.m')
end
describe 'deals with invalid source file references' do
before do
file_accessor = @pod_target.file_accessors.first
@first_header_file = file_accessor.source_files.find { |sf| sf.extname == '.h' }
@first_source_file = file_accessor.source_files.find { |sf| sf.extname == '.m' }
@header_symlink_file = @first_header_file.dirname + "SymLinkOf-#{@first_header_file.basename}"
@source_symlink_file = @first_source_file.dirname + "SymLinkOf-#{@first_source_file.basename}"
FileUtils.rm_f(@header_symlink_file.to_s)
FileUtils.rm_f(@source_symlink_file.to_s)
end
after do
FileUtils.rm_f(@header_symlink_file.to_s)
FileUtils.rm_f(@source_symlink_file.to_s)
end
it 'raises when source file reference is not found' do
File.symlink(@first_source_file, @source_symlink_file)
path_list = Sandbox::PathList.new(fixture('banana-lib'))
file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios))
@pod_target.file_accessors = [file_accessor]
exception = lambda { @installer.install! }.should.raise Informative
exception.message.should.include "Unable to find source ref for #{@source_symlink_file} for target BananaLib."
end
it 'raises when header file reference is not found' do
File.symlink(@first_header_file, @header_symlink_file)
path_list = Sandbox::PathList.new(fixture('banana-lib'))
file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios))
@pod_target.file_accessors = [file_accessor]
exception = lambda { @installer.install! }.should.raise Informative
exception.message.should.include "Unable to find header ref for #{@header_symlink_file} for target BananaLib."
end
it 'does not raise when header file reference is found' do
File.symlink(@first_header_file, @header_symlink_file)
path_list = Sandbox::PathList.new(fixture('banana-lib'))
file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios))
@pod_target.file_accessors = [file_accessor]
group = @project.group_for_spec('BananaLib')
@project.add_file_reference(@header_symlink_file.to_s, group)
lambda { @installer.install! }.should.not.raise
end
it 'does not raise when source file reference is found' do
File.symlink(@first_source_file, @source_symlink_file)
path_list = Sandbox::PathList.new(fixture('banana-lib'))
file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios))
@pod_target.file_accessors = [file_accessor]
group = @project.group_for_spec('BananaLib')
@project.add_file_reference(@source_symlink_file.to_s, group)
lambda { @installer.install! }.should.not.raise
end
end
#--------------------------------------#
it 'adds framework resources to the framework target' 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