Correctly handle `OTHER_LDFLAGS` for targets with inherit search paths and source pods.

parent d597f715
...@@ -14,6 +14,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -14,6 +14,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes ##### Bug Fixes
* Correctly handle `OTHER_LDFLAGS` for targets with inherit search paths and source pods.
[Justin Martin](https://github.com/justinseanmartin)
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6481](https://github.com/CocoaPods/CocoaPods/pull/6481)
* Do not generate `UIRequiredDeviceCapabilities` for `tvOS` Info.plists. * Do not generate `UIRequiredDeviceCapabilities` for `tvOS` Info.plists.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6193](https://github.com/CocoaPods/CocoaPods/issues/6193) [#6193](https://github.com/CocoaPods/CocoaPods/issues/6193)
......
...@@ -198,11 +198,11 @@ module Pod ...@@ -198,11 +198,11 @@ module Pod
if pod_target.requires_frameworks? if pod_target.requires_frameworks?
%(-framework "#{pod_target.product_basename}") %(-framework "#{pod_target.product_basename}")
else else
%(-l "#{pod_target.product_basename}") %(-l "#{pod_target.product_basename}") if XCConfigHelper.links_dependency?(target, pod_target)
end end
end end
@xcconfig.merge!('OTHER_LDFLAGS' => other_ld_flags.join(' ')) @xcconfig.merge!('OTHER_LDFLAGS' => other_ld_flags.compact.join(' '))
end end
# Ensure to add the default linker run path search paths as they could # Ensure to add the default linker run path search paths as they could
......
...@@ -103,11 +103,11 @@ module Pod ...@@ -103,11 +103,11 @@ module Pod
# #
def self.add_static_dependency_build_settings(aggregate_target, pod_target, xcconfig, file_accessor) def self.add_static_dependency_build_settings(aggregate_target, pod_target, xcconfig, file_accessor)
file_accessor.vendored_static_frameworks.each do |vendored_static_framework| file_accessor.vendored_static_frameworks.each do |vendored_static_framework|
adds_other_ldflags = XCConfigHelper.links_static_dependency?(aggregate_target, pod_target) adds_other_ldflags = XCConfigHelper.links_dependency?(aggregate_target, pod_target)
XCConfigHelper.add_framework_build_settings(vendored_static_framework, xcconfig, pod_target.sandbox.root, adds_other_ldflags) XCConfigHelper.add_framework_build_settings(vendored_static_framework, xcconfig, pod_target.sandbox.root, adds_other_ldflags)
end end
file_accessor.vendored_static_libraries.each do |vendored_static_library| file_accessor.vendored_static_libraries.each do |vendored_static_library|
adds_other_ldflags = XCConfigHelper.links_static_dependency?(aggregate_target, pod_target) adds_other_ldflags = XCConfigHelper.links_dependency?(aggregate_target, pod_target)
XCConfigHelper.add_library_build_settings(vendored_static_library, xcconfig, pod_target.sandbox.root, adds_other_ldflags) XCConfigHelper.add_library_build_settings(vendored_static_library, xcconfig, pod_target.sandbox.root, adds_other_ldflags)
end end
end end
...@@ -122,15 +122,10 @@ module Pod ...@@ -122,15 +122,10 @@ module Pod
# of the aggregate target. Aggregate targets that inherit search paths will only link # of the aggregate target. Aggregate targets that inherit search paths will only link
# if the target has explicitly declared the pod dependency. # if the target has explicitly declared the pod dependency.
# #
def self.links_static_dependency?(aggregate_target, pod_target) def self.links_dependency?(aggregate_target, pod_target)
return true if aggregate_target.nil? || aggregate_target.target_definition.inheritance != 'search_paths' return true if aggregate_target.nil? || aggregate_target.target_definition.inheritance == 'complete'
# Only link this static dependency if its explicitly defined for this target. targets = aggregate_target.pod_targets - aggregate_target.search_paths_aggregate_targets.flat_map(&:pod_targets)
aggregate_target.target_definition.non_inherited_dependencies.each do |d| targets.include?(pod_target)
if d.name == pod_target.name
return true
end
end
false
end end
# Adds build settings for dynamic vendored frameworks and libraries. # Adds build settings for dynamic vendored frameworks and libraries.
......
...@@ -233,8 +233,8 @@ module Pod ...@@ -233,8 +233,8 @@ module Pod
end end
it 'should not include static framework other ld flags when inheriting search paths' do it 'should not include static framework other ld flags when inheriting search paths' do
target_definition = stub(:inheritance => 'search_paths', :non_inherited_dependencies => []) target_definition = stub(:inheritance => 'search_paths')
aggregate_target = stub(:target_definition => target_definition, :pod_targets => []) aggregate_target = stub(:target_definition => target_definition, :pod_targets => [], :search_paths_aggregate_targets => [])
pod_target = stub(:sandbox => config.sandbox) pod_target = stub(:sandbox => config.sandbox)
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
@sut.add_static_dependency_build_settings(aggregate_target, pod_target, xcconfig, @accessor) @sut.add_static_dependency_build_settings(aggregate_target, pod_target, xcconfig, @accessor)
...@@ -244,10 +244,9 @@ module Pod ...@@ -244,10 +244,9 @@ module Pod
end end
it 'should include static framework other ld flags when inheriting search paths but explicitly declared' do it 'should include static framework other ld flags when inheriting search paths but explicitly declared' do
dependency = stub(:name => 'BananaLib') target_definition = stub(:inheritance => 'search_paths')
target_definition = stub(:inheritance => 'search_paths', :non_inherited_dependencies => [dependency])
pod_target = stub(:name => 'BananaLib', :sandbox => config.sandbox) pod_target = stub(:name => 'BananaLib', :sandbox => config.sandbox)
aggregate_target = stub(:target_definition => target_definition, :pod_targets => [pod_target]) aggregate_target = stub(:target_definition => target_definition, :pod_targets => [pod_target], :search_paths_aggregate_targets => [])
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
@sut.add_static_dependency_build_settings(aggregate_target, pod_target, xcconfig, @accessor) @sut.add_static_dependency_build_settings(aggregate_target, pod_target, xcconfig, @accessor)
xcconfig.to_hash['LIBRARY_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/../../spec/fixtures/banana-lib"' xcconfig.to_hash['LIBRARY_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/../../spec/fixtures/banana-lib"'
...@@ -274,6 +273,60 @@ module Pod ...@@ -274,6 +273,60 @@ module Pod
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '"${PODS_ROOT}/../../spec/fixtures/banana-lib"' xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should == '"${PODS_ROOT}/../../spec/fixtures/banana-lib"'
xcconfig.to_hash['OTHER_LDFLAGS'].should == '-l"Bananalib" -framework "Bananalib"' xcconfig.to_hash['OTHER_LDFLAGS'].should == '-l"Bananalib" -framework "Bananalib"'
end end
it 'should link static dependency for pod targets' do
pod_target = stub(:name => 'BananaLib', :sandbox => config.sandbox)
@sut.links_dependency?(nil, pod_target).should.be.true
end
it 'should link static dependency when target explicitly specifies it' do
target_definition = stub(:inheritance => 'complete')
pod_target = stub(:name => 'BananaLib', :sandbox => config.sandbox)
aggregate_target = stub(:target_definition => target_definition, :pod_targets => [pod_target], :search_paths_aggregate_targets => [])
@sut.links_dependency?(aggregate_target, pod_target).should.be.true
end
it 'should link static dependency when target explicitly specifies it even with search paths' do
target_definition = stub(:inheritance => 'search_paths')
pod_target = stub(:name => 'BananaLib', :sandbox => config.sandbox)
aggregate_target = stub(:target_definition => target_definition, :pod_targets => [pod_target], :search_paths_aggregate_targets => [])
@sut.links_dependency?(aggregate_target, pod_target).should.be.true
end
it 'should not link static dependency when inheriting search paths and parent includes dependency' do
parent_target_definition = stub
child_target_definition = stub(:inheritance => 'search_paths')
pod_target = stub(:name => 'BananaLib', :sandbox => config.sandbox)
parent_aggregate_target = stub(:target_definition => parent_target_definition, :pod_targets => [pod_target], :search_paths_aggregate_targets => [])
child_aggregate_target = stub(:target_definition => child_target_definition, :pod_targets => [], :search_paths_aggregate_targets => [parent_aggregate_target])
@sut.links_dependency?(child_aggregate_target, pod_target).should.be.false
end
it 'should link static transitive dependencies if the parent does not link them' do
child_pod_target = stub(:name => 'ChildPod', :sandbox => config.sandbox)
parent_pod_target = stub(:name => 'ParentPod', :sandbox => config.sandbox, :dependent_targets => [child_pod_target])
parent_target_definition = stub
child_target_definition = stub(:inheritance => 'search_paths')
parent_aggregate_target = stub(:target_definition => parent_target_definition, :pod_targets => [], :search_paths_aggregate_targets => [])
child_aggregate_target = stub(:target_definition => child_target_definition, :pod_targets => [parent_pod_target, child_pod_target], :search_paths_aggregate_targets => [parent_aggregate_target])
@sut.links_dependency?(child_aggregate_target, child_pod_target).should.be.true
@sut.links_dependency?(child_aggregate_target, parent_pod_target).should.be.true
end
it 'should link static only transitive dependencies that the parent does not link' do
child_pod_target = stub(:name => 'ChildPod', :sandbox => config.sandbox)
parent_pod_target = stub(:name => 'ParentPod', :sandbox => config.sandbox, :dependent_targets => [child_pod_target])
parent_target_definition = stub
child_target_definition = stub(:inheritance => 'search_paths')
parent_aggregate_target = stub(:target_definition => parent_target_definition, :pod_targets => [child_pod_target], :search_paths_aggregate_targets => [])
child_aggregate_target = stub(:target_definition => child_target_definition, :pod_targets => [parent_pod_target, child_pod_target], :search_paths_aggregate_targets => [parent_aggregate_target])
@sut.links_dependency?(child_aggregate_target, child_pod_target).should.be.false
@sut.links_dependency?(child_aggregate_target, parent_pod_target).should.be.true
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