Commit c679ae82 authored by Paul Beusterien's avatar Paul Beusterien

Fix OTHER_LDFLAGS for projects including source static frameworks

parent a75a2e85
......@@ -16,14 +16,18 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
dependency resolution.
[Samuel Giddins](https://github.com/segiddins)
* Add support for source static library frameworks
* Add support for source static library frameworks
[Paul Beusterien](https://github.com/paulb777)
[#6811](https://github.com/CocoaPods/CocoaPods/pull/6811)
* Add Private Header support to static frameworks
* Add Private Header support to static frameworks
[Paul Beusterien](https://github.com/paulb777)
[#6969](https://github.com/CocoaPods/CocoaPods/pull/6969)
* For source static frameworks, include frameworks from dependent targets and libraries in OTHER_LDFLAGS
[paulb777](https://github.com/paulb777)
[#6988](https://github.com/CocoaPods/CocoaPods/pull/6988)
##### Bug Fixes
* Perform code signing on xctest bundles in the Pods project generated by a test spec
......
......@@ -170,11 +170,11 @@ module Pod
# - `@import …;` / `import …`
#
def generate_settings_to_import_pod_targets
@xcconfig.merge! XCConfigHelper.settings_for_dependent_targets(target, pod_targets)
@xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(target, pod_targets)
@xcconfig.merge!(settings_to_import_pod_targets)
target.search_paths_aggregate_targets.each do |search_paths_target|
generator = AggregateXCConfig.new(search_paths_target, configuration_name)
@xcconfig.merge! XCConfigHelper.settings_for_dependent_targets(nil, search_paths_target.pod_targets)
@xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(nil, search_paths_target.pod_targets)
@xcconfig.merge!(generator.settings_to_import_pod_targets)
end
end
......
......@@ -70,10 +70,10 @@ module Pod
end
XCConfigHelper.add_target_specific_settings(target, @xcconfig)
recursive_dependent_targets = target.recursive_dependent_targets
@xcconfig.merge! XCConfigHelper.settings_for_dependent_targets(target, recursive_dependent_targets, @test_xcconfig)
@xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(target, recursive_dependent_targets, @test_xcconfig)
if @test_xcconfig
test_dependent_targets = [target, *target.recursive_test_dependent_targets].uniq
@xcconfig.merge! XCConfigHelper.settings_for_dependent_targets(target, test_dependent_targets - recursive_dependent_targets, @test_xcconfig)
@xcconfig.merge! XCConfigHelper.search_paths_for_dependent_targets(target, test_dependent_targets - recursive_dependent_targets, @test_xcconfig)
XCConfigHelper.generate_vendored_build_settings(nil, target.all_test_dependent_targets, @xcconfig)
XCConfigHelper.generate_other_ld_flags(nil, target.all_test_dependent_targets, @xcconfig)
XCConfigHelper.generate_ld_runpath_search_paths(target, false, true, @xcconfig)
......
......@@ -270,7 +270,7 @@ module Pod
#
# @return [Hash<String, String>] the settings
#
def self.settings_for_dependent_targets(target, dependent_targets, test_xcconfig = false)
def self.search_paths_for_dependent_targets(target, dependent_targets, test_xcconfig = false)
dependent_targets = dependent_targets.select(&:should_build?)
# Filter out dependent targets that are subsets of another target.
......@@ -332,7 +332,7 @@ module Pod
#
def self.generate_vendored_build_settings(aggregate_target, pod_targets, xcconfig)
pod_targets.each do |pod_target|
unless pod_target.should_build? && pod_target.requires_frameworks?
unless pod_target.should_build? && pod_target.requires_frameworks? && !pod_target.static_framework?
XCConfigHelper.add_settings_for_file_accessors_of_target(aggregate_target, pod_target, xcconfig)
end
end
......@@ -396,6 +396,16 @@ module Pod
# @return [void]
#
def self.generate_other_ld_flags(aggregate_target, pod_targets, xcconfig)
# Make sure -framework option gets added for the search paths when static_frameworks are involved.
# Otherwise test targets won't link in their primary target's dependencies.
unless aggregate_target.nil?
dependent_targets = aggregate_target.search_paths_aggregate_targets
dependent_targets.each do |dependent_target|
if dependent_target.pod_targets.any?(&:static_framework?)
generate_other_ld_flags(dependent_target, dependent_target.pod_targets, xcconfig)
end
end
end
other_ld_flags = pod_targets.select(&:should_build?).map do |pod_target|
if pod_target.requires_frameworks?
%(-framework "#{pod_target.product_basename}")
......
......@@ -77,10 +77,88 @@ module Pod
:configuration_build_dir => 'B',
)
dependent_targets = [target1, target2]
build_settings = @sut.settings_for_dependent_targets(nil, dependent_targets)
build_settings = @sut.search_paths_for_dependent_targets(nil, dependent_targets)
build_settings['FRAMEWORK_SEARCH_PATHS'].should == '"AB"'
end
it 'adds the libraries of the xcconfig for a static framework' do
target_definition = stub(:inheritance => 'search_paths')
consumer = stub(
:pod_target_xcconfig => {},
:libraries => ['xml2'],
:frameworks => [],
:weak_frameworks => [],
:platform_name => :ios,
)
file_accessor = stub(
:spec_consumer => consumer,
:vendored_static_frameworks => [],
:vendored_dynamic_frameworks => [],
:vendored_static_libraries => [],
:vendored_dynamic_libraries => [],
)
pod_target = stub(
:name => 'BananaLib',
:sandbox => config.sandbox,
:should_build? => true,
:requires_frameworks? => true,
:static_framework? => true,
:dependent_targets => [],
:file_accessors => [file_accessor],
)
pod_targets = [pod_target]
aggregate_target = stub(
:target_definition => target_definition,
:pod_targets => pod_targets,
:search_paths_aggregate_targets => [],
)
xcconfig = Xcodeproj::Config.new
@sut.generate_vendored_build_settings(aggregate_target, pod_targets, xcconfig)
xcconfig.to_hash['OTHER_LDFLAGS'].should == '-l"xml2"'
end
it 'makes sure setting from search_paths get propagated for static frameworks' do
target_definition = stub(:inheritance => 'search_paths')
consumer = stub(
:pod_target_xcconfig => {},
:libraries => ['xml2'],
:frameworks => ['Foo'],
:weak_frameworks => [],
:platform_name => :ios,
)
file_accessor = stub(
:spec_consumer => consumer,
:vendored_static_frameworks => [],
:vendored_dynamic_frameworks => [],
:vendored_static_libraries => [],
:vendored_dynamic_libraries => [],
)
pod_target = stub(
:name => 'BananaLib',
:sandbox => config.sandbox,
:should_build? => true,
:requires_frameworks? => true,
:static_framework? => true,
:dependent_targets => [],
:file_accessors => [file_accessor],
:product_basename => 'Foo',
)
pod_targets = [pod_target]
aggregate_target = stub(
:target_definition => target_definition,
:pod_targets => pod_targets,
:search_paths_aggregate_targets => [],
)
test_aggregate_target = stub(
:target_definition => target_definition,
:pod_targets => [],
:search_paths_aggregate_targets => [aggregate_target],
)
xcconfig = Xcodeproj::Config.new
@sut.generate_other_ld_flags(test_aggregate_target, [], xcconfig)
xcconfig.to_hash['OTHER_LDFLAGS'].should == '-framework "Foo"'
end
it 'adds the frameworks of the xcconfig' do
xcconfig = Xcodeproj::Config.new
consumer = stub(
......
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