Commit dfd3ed6c authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #4106 from CocoaPods/use-realpath-for-development-pods

Fix Swift code completion for Development Pods
parents 313ffd35 67e4aca2
......@@ -136,6 +136,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins)
[#4514](https://github.com/CocoaPods/CocoaPods/issues/4514)
* Fix Swift code completion for Development Pods by using `realpath` for
symlinked source files.
[Boris Bügling](https://github.com/neonichu)
[#3777](https://github.com/CocoaPods/CocoaPods/issues/3777)
## 0.39.0 (2015-10-09)
......
......@@ -179,13 +179,13 @@ module Pod
# @return [PBXFileReference] The new file reference.
#
def add_file_reference(absolute_path, group, reflect_file_system_structure = false)
file_path_name = Pathname.new(absolute_path)
file_path_name = absolute_path.is_a?(Pathname) ? absolute_path : Pathname.new(absolute_path)
group = group_for_path_in_group(file_path_name, group, reflect_file_system_structure)
if ref = reference_for_path(absolute_path)
if ref = reference_for_path(file_path_name.realpath)
ref
else
ref = group.new_file(absolute_path)
ref = group.new_file(file_path_name.realpath)
@refs_by_absolute_path[absolute_path.to_s] = ref
end
end
......
......@@ -252,24 +252,30 @@ module Pod
pod 'monkey', :path => (fixture_path + 'monkey').to_s
end
@lockfile = generate_lockfile
@file = Pathname('/yolo.m')
@file.stubs(:realpath).returns(@file)
@lib_thing = Pathname('/libThing.a')
@lib_thing.stubs(:realpath).returns(@lib_thing)
end
it 'detects transitive static dependencies which are linked directly to the user target' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([Pathname('/libThing.a')])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@installer = Installer.new(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @installer.install! }.message.should.match /transitive.*libThing/
end
it 'allows transitive static dependencies which contain other source code' do
Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([Pathname('/yolo.m')])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([Pathname('/libThing.a')])
Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([@file])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@installer = Installer.new(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @installer.install! }
end
it 'allows transitive static dependencies when both dependencies are linked against the user target' do
PodTarget.any_instance.stubs(:should_build? => false)
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([Pathname('/libThing.a')])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@installer = Installer.new(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @installer.install! }
end
......
......@@ -174,26 +174,31 @@ module Pod
end
it 'adds a file references to the given file' do
Pathname.any_instance.stubs(:realpath).returns(@file)
ref = @project.add_file_reference(@file, @group)
ref.hierarchy_path.should == '/Pods/BananaLib/file.m'
end
it 'adds subgroups for a file reference if requested' do
Pathname.any_instance.stubs(:realpath).returns(@nested_file)
ref = @project.add_file_reference(@nested_file, @group, true)
ref.hierarchy_path.should == '/Pods/BananaLib/Dir/SubDir/nested_file.m'
end
it 'does not add subgroups for a file reference if not requested' do
Pathname.any_instance.stubs(:realpath).returns(@nested_file)
ref = @project.add_file_reference(@nested_file, @group)
ref.hierarchy_path.should == '/Pods/BananaLib/nested_file.m'
end
it 'does not add subgroups for a file reference if requested not to' do
Pathname.any_instance.stubs(:realpath).returns(@nested_file)
ref = @project.add_file_reference(@nested_file, @group, false)
ref.hierarchy_path.should == '/Pods/BananaLib/nested_file.m'
end
it "it doesn't duplicate file references for a single path" do
Pathname.any_instance.stubs(:realpath).returns(@file)
ref_1 = @project.add_file_reference(@file, @group)
ref_2 = @project.add_file_reference(@file, @group)
ref_1.uuid.should == ref_2.uuid
......@@ -201,12 +206,14 @@ module Pod
end
it 'creates variant group for localized file' do
Pathname.any_instance.stubs(:realpath).returns(@localized_file)
ref = @project.add_file_reference(@localized_file, @group)
ref.hierarchy_path.should == '/Pods/BananaLib/Foo/Foo.strings'
ref.parent.class.should == Xcodeproj::Project::Object::PBXVariantGroup
end
it 'creates variant group for localized file in subgroup' do
Pathname.any_instance.stubs(:realpath).returns(@localized_file)
ref = @project.add_file_reference(@localized_file, @group, true)
ref.hierarchy_path.should == '/Pods/BananaLib/Dir/SubDir/Foo/Foo.strings'
ref.parent.class.should == Xcodeproj::Project::Object::PBXVariantGroup
......@@ -217,6 +224,18 @@ module Pod
@project.add_file_reference('relative/path/to/file.m', @group)
end.message.should.match /Paths must be absolute/
end
it 'uses realpath for resolving symlinks' do
file = Pathname.new(Dir.tmpdir) + 'file.m'
FileUtils.rm_f(file)
File.open(file, 'w') { |f| f.write('') }
sym_file = Pathname.new(Dir.tmpdir) + 'symlinked_file.m'
FileUtils.rm_f(sym_file)
File.symlink(file, sym_file)
ref = @project.add_file_reference(sym_file, @group)
ref.hierarchy_path.should == '/Pods/BananaLib/file.m'
end
end
#----------------------------------------#
......@@ -312,6 +331,7 @@ module Pod
@project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'), false)
@file = config.sandbox.pod_dir('BananaLib') + 'file.m'
@group = @project.group_for_spec('BananaLib')
Pathname.any_instance.stubs(:realpath).returns(@file)
@project.add_file_reference(@file, @group)
end
......
......@@ -729,9 +729,11 @@ module Pod
def test_swiftpod
podspec = stub_podspec(/.*source_files.*/, '"source_files": "*.swift",')
file = write_podspec(podspec)
pathname = Pathname.new('/Foo.swift')
pathname.stubs(:realpath).returns(pathname)
Podfile::TargetDefinition.any_instance.stubs(:uses_frameworks?).returns(true)
Pod::Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([Pathname.new('/Foo.swift')])
Pod::Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([pathname])
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:build_pod)
validator.stubs(:validate_url)
......
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