今是昨非

今是昨非

日出江花红胜火,春来江水绿如蓝

The 'Pods-App' target has dependencies that include static binaries.

The 'Pods-App' target has transitive dependencies that include static binaries: Modification#

Background#

Recently, I encountered this problem twice in a Swift project where adding libraries to the Pod with use_frameworks! enabled resulted in errors when installing certain Objective-C libraries. It took me a long time to resolve it. Suddenly, I remembered that I had encountered the same problem when installing Swift libraries in an Objective-C project before, but I didn't document it at that time, so I didn't have any recollection when I encountered it this time. This time, I'm documenting it and sharing it with everyone:

Solution#

Previously, I encountered this issue when installing the Swift library of ZLPhotoBrowser in Objective-C code with use_frameworks! enabled. When installing it together with other third-party libraries, it can be understood that, except for ZLPhotoBrowser, which is a dynamic library, the other third-party libraries are by default using static_framework or static_library.

Add the following code to the end of the Podfile:


use_frameworks!

...

dynamic_frameworks = ['ZLPhotoBrowser']
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if !dynamic_frameworks.include?(pod.name)
      def pod.static_framework?;
        true
      end
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

This time, it is installing Pod libraries in Swift code with use_frameworks! enabled. However, what is desired here is that, except for certain libraries, which should use static_framework or static_library, all other libraries should use use_frameworks! by default.

Therefore, add the following code to the end of the Podfile:


use_frameworks!

...

# Libraries to use Objective-C
static_frameworks = ['xxx', 'yyy']
pre_install do |installer|
  installer.pod_targets.each do |pod|
    # Note the difference here compared to the previous code
    if static_frameworks.include?(pod.name)
      def pod.static_framework?;
        true
      end
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.