From 4b8b20947d97e5181c4408932e3472b719b98a28 Mon Sep 17 00:00:00 2001 From: Martin Fiebig Date: Mon, 13 May 2019 15:56:05 +0200 Subject: [PATCH 1/2] Fix linking/bundling of static frameworks of an app extension into the app --- CHANGELOG.md | 2 ++ lib/cocoapods/installer/analyzer.rb | 3 ++- spec/unit/installer/analyzer_spec.rb | 31 ++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b44f665f3..7a246a6979 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ To install release candidates run `[sudo] gem install cocoapods --pre` [Dimitris Koutsogiorgas](https://github.com/dnkoutso) [#8585](https://github.com/CocoaPods/CocoaPods/pull/8585) +* Fix embedding static frameworks in extensions while using `use_frameworks!` + [Martin Fiebig](https://github.com/mfiebig) ## 1.7.0.rc.1 (2019-05-02) diff --git a/lib/cocoapods/installer/analyzer.rb b/lib/cocoapods/installer/analyzer.rb index 583639f737..fdfcdd5d7d 100644 --- a/lib/cocoapods/installer/analyzer.rb +++ b/lib/cocoapods/installer/analyzer.rb @@ -303,7 +303,8 @@ def embedded_target_pod_targets_by_host(aggregate_target, embedded_aggregate_tar pod_target_names = Set.new(aggregate_target.pod_targets_for_build_configuration(configuration_name).map(&:name)) embedded_pod_targets = embedded_aggregate_target.pod_targets_for_build_configuration(configuration_name).select do |pod_target| if !pod_target_names.include?(pod_target.name) && - aggregate_target.pod_targets.none? { |aggregate_pod_target| (pod_target.specs - aggregate_pod_target.specs).empty? } + aggregate_target.pod_targets.none? { |aggregate_pod_target| (pod_target.specs - aggregate_pod_target.specs).empty? } && + (libraries_only || pod_target.build_as_dynamic?) pod_target.name end end diff --git a/spec/unit/installer/analyzer_spec.rb b/spec/unit/installer/analyzer_spec.rb index 797dfa5218..4aae90d549 100644 --- a/spec/unit/installer/analyzer_spec.rb +++ b/spec/unit/installer/analyzer_spec.rb @@ -1162,6 +1162,37 @@ module Pod ].sort end + it 'does not copy extension pod targets to host target, when use_frameworks! but contained pod is static' do + SpecHelper.create_sample_app_copy_from_fixture('Sample Extensions Project') + fixture_path = ROOT + 'spec/fixtures' + podfile = Pod::Podfile.new do + source SpecHelper.test_repo_url + platform :ios, '6.0' + project 'Sample Extensions Project/Sample Extensions Project' + use_frameworks! + + target 'Sample Extensions Project' do + pod 'JSONKit', '1.4' + end + + target 'Today Extension' do + pod 'matryoshka', :path => (fixture_path + 'static-matryoshka').to_s + end + end + + analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile) + # Create 'Local Podspecs' folder within target project + Dir.mkdir(File.join(config.sandbox.root, 'Local Podspecs')) + result = analyzer.analyze + + result.targets.flat_map { |at| at.pod_targets.map { |pt| "#{at.name}/#{pt.name}" } }.sort.should == [ + 'Pods-Sample Extensions Project/JSONKit', + 'Pods-Sample Extensions Project/monkey', + 'Pods-Today Extension/monkey', + 'Pods-Today Extension/matryoshka', + ].sort + end + it 'copies pod targets of frameworks and libraries from within sub projects' do podfile = Pod::Podfile.new do source SpecHelper.test_repo_url From d7599a34aadd29992fa622d7888b9492155a8707 Mon Sep 17 00:00:00 2001 From: Martin Fiebig Date: Tue, 14 May 2019 09:49:12 +0200 Subject: [PATCH 2/2] Improve Changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a246a6979..757abe2cc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ To install release candidates run `[sudo] gem install cocoapods --pre` * Fix embedding static frameworks in extensions while using `use_frameworks!` [Martin Fiebig](https://github.com/mfiebig) + [#8798](https://github.com/CocoaPods/CocoaPods/pull/8798) ## 1.7.0.rc.1 (2019-05-02)