From de0360b5620aabc2136c95e6ce9f47923e6a29bf Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Wed, 24 Feb 2021 10:00:08 -0800 Subject: [PATCH 1/3] fix missing -objc for xcframeworks - take 2 --- CHANGELOG.md | 4 ++++ lib/cocoapods/sandbox/file_accessor.rb | 4 ++-- lib/cocoapods/target/build_settings.rb | 16 ---------------- spec/unit/target/build_settings_spec.rb | 16 +--------------- 4 files changed, 7 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37b121d5b6..66564a4b44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ##### Bug Fixes +* Fix missing `-ObjC` for static XCFrameworks - take 2 + [Paul Beusterien](https://github.com/paulb777) + [#10459](https://github.com/CocoaPods/CocoaPods/issuess/10459) + * Change URL validation failure to a note [Paul Beusterien](https://github.com/paulb777) [#10291](https://github.com/CocoaPods/CocoaPods/issues/10291) diff --git a/lib/cocoapods/sandbox/file_accessor.rb b/lib/cocoapods/sandbox/file_accessor.rb index 8018782336..8c56181fb3 100644 --- a/lib/cocoapods/sandbox/file_accessor.rb +++ b/lib/cocoapods/sandbox/file_accessor.rb @@ -167,7 +167,7 @@ def vendored_frameworks # that come shipped with the Pod. # def vendored_dynamic_frameworks - (vendored_frameworks - vendored_xcframeworks).select do |framework| + vendored_frameworks.select do |framework| Xcode::LinkageAnalyzer.dynamic_binary?(framework + framework.basename('.*')) end end @@ -176,7 +176,7 @@ def vendored_dynamic_frameworks # bundles that come shipped with the Pod. # def vendored_static_frameworks - vendored_frameworks - vendored_dynamic_frameworks - vendored_xcframeworks + vendored_frameworks - vendored_dynamic_frameworks end # @return [Array] The paths of vendored .xcframework bundles diff --git a/lib/cocoapods/target/build_settings.rb b/lib/cocoapods/target/build_settings.rb index e1d6e47452..63c297559d 100644 --- a/lib/cocoapods/target/build_settings.rb +++ b/lib/cocoapods/target/build_settings.rb @@ -1263,24 +1263,8 @@ def other_swift_flags_without_swift? end end - # @return [Boolean] - define_build_settings_method :any_vendored_static_xcframeworks?, :memoized => true do - pod_targets.any? do |pt| - pt.build_settings.any? do |bs| - if bs.respond_to?(:vendored_xcframeworks) - bs.vendored_xcframeworks.any? do |xcf| - xcf.build_type == BuildType.static_framework - end - end - end - end - end - # @return [Boolean] define_build_settings_method :any_vendored_static_artifacts?, :memoized => true do - if any_vendored_static_xcframeworks? - return true - end pod_targets.any? do |pt| pt.file_accessors.any? do |fa| !fa.vendored_static_artifacts.empty? diff --git a/spec/unit/target/build_settings_spec.rb b/spec/unit/target/build_settings_spec.rb index a9c63846e0..0cf11a89d7 100644 --- a/spec/unit/target/build_settings_spec.rb +++ b/spec/unit/target/build_settings_spec.rb @@ -352,19 +352,13 @@ def aggregate(aggregate_target, configuration_name = 'Release') file_accessor = stub('file_accessor', :spec => spec, :spec_consumer => consumer, - :vendored_static_artifacts => [], + :vendored_static_artifacts => [1, 2, 3], :vendored_static_libraries => [], :vendored_dynamic_libraries => [], :vendored_static_frameworks => [], :vendored_dynamic_frameworks => [], :vendored_xcframeworks => [], ) - vendored_xcframework = stub('vendored_xcframework', - :build_type => BuildType.static_framework, - ) - build_setting = stub('build_setting', - :vendored_xcframeworks => [vendored_xcframework], - ) pod_target = stub('pod_target', :any_vendored_static_artifacts? => true, :file_accessors => [file_accessor], @@ -377,7 +371,6 @@ def aggregate(aggregate_target, configuration_name = 'Release') :spec_consumers => [consumer], :build_as_static? => false, :build_as_dynamic? => false, - :build_settings => [build_setting], :product_basename => 'PodTarget', :target_definitions => [target_definition], :root_spec => spec, @@ -407,12 +400,6 @@ def aggregate(aggregate_target, configuration_name = 'Release') :vendored_dynamic_frameworks => [], :vendored_xcframeworks => [], ) - vendored_xcframework = stub('vendored_xcframework', - :build_type => BuildType.dynamic_framework, - ) - build_setting = stub('build_setting', - :vendored_xcframeworks => [vendored_xcframework], - ) pod_target = stub('pod_target', :any_vendored_static_artifacts? => true, :file_accessors => [file_accessor], @@ -425,7 +412,6 @@ def aggregate(aggregate_target, configuration_name = 'Release') :spec_consumers => [consumer], :build_as_static? => false, :build_as_dynamic? => false, - :build_settings => [build_setting], :product_basename => 'PodTarget', :target_definitions => [target_definition], :root_spec => spec, From bdbd95687a91d5470b343498622963d590518248 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Wed, 24 Feb 2021 17:06:24 -0800 Subject: [PATCH 2/3] Fixes and integration test update --- lib/cocoapods/sandbox/file_accessor.rb | 17 ++++++++++++++--- spec/cocoapods-integration-specs | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/cocoapods/sandbox/file_accessor.rb b/lib/cocoapods/sandbox/file_accessor.rb index 8c56181fb3..5ac6f7ae86 100644 --- a/lib/cocoapods/sandbox/file_accessor.rb +++ b/lib/cocoapods/sandbox/file_accessor.rb @@ -167,16 +167,27 @@ def vendored_frameworks # that come shipped with the Pod. # def vendored_dynamic_frameworks - vendored_frameworks.select do |framework| + (vendored_frameworks - vendored_xcframeworks).select do |framework| Xcode::LinkageAnalyzer.dynamic_binary?(framework + framework.basename('.*')) end end + # @return [Array] The paths of the dynamic xcframework bundles + # that come shipped with the Pod. + # + def vendored_static_xcframeworks + vendored_xcframeworks.select do |path| + if Xcode::XCFramework.new(path).build_type == BuildType.static_framework + path + end + end + end + # @return [Array] The paths of the static (fake) framework # bundles that come shipped with the Pod. # def vendored_static_frameworks - vendored_frameworks - vendored_dynamic_frameworks + vendored_frameworks - vendored_dynamic_frameworks - vendored_xcframeworks end # @return [Array] The paths of vendored .xcframework bundles @@ -289,7 +300,7 @@ def vendored_dynamic_artifacts # that come shipped with the Pod. # def vendored_static_artifacts - vendored_static_libraries + vendored_static_frameworks + vendored_static_libraries + vendored_static_frameworks + vendored_static_xcframeworks end # @return [Hash{String => Array}] A hash that describes the diff --git a/spec/cocoapods-integration-specs b/spec/cocoapods-integration-specs index 09cf02c582..536f201f72 160000 --- a/spec/cocoapods-integration-specs +++ b/spec/cocoapods-integration-specs @@ -1 +1 @@ -Subproject commit 09cf02c5825722693622b3f794a3603ec15e992e +Subproject commit 536f201f729e5336150b5f9d1e0284b280b47677 From 725e96928269b4eac40d94cb3388a4e32a58d69b Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Tue, 9 Mar 2021 11:01:26 -0800 Subject: [PATCH 3/3] Review feedback --- lib/cocoapods/sandbox/file_accessor.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/cocoapods/sandbox/file_accessor.rb b/lib/cocoapods/sandbox/file_accessor.rb index 5ac6f7ae86..37ddf26193 100644 --- a/lib/cocoapods/sandbox/file_accessor.rb +++ b/lib/cocoapods/sandbox/file_accessor.rb @@ -177,9 +177,7 @@ def vendored_dynamic_frameworks # def vendored_static_xcframeworks vendored_xcframeworks.select do |path| - if Xcode::XCFramework.new(path).build_type == BuildType.static_framework - path - end + Xcode::XCFramework.new(path).build_type == BuildType.static_framework end end