The 'Pods-App' target has transitive dependencies that include static binaries: Modification#
Background#
Recently, I encountered this problem twice in a Swift project when adding libraries through Pods with use_frameworks!
enabled. There was an error when installing certain Objective-C libraries. It took a long time to resolve. Suddenly, I remembered that I had encountered this problem before when installing Swift libraries in an Objective-C project, but I didn't document it at that time. So this time, I'm documenting it and sharing it with everyone:
Solution#
Previously, I encountered the issue of installing a Swift library, ZLPhotoBrowser
, in Objective-C code with use_frameworks!
enabled. When installing it together with other third-party libraries, it can be understood that all libraries, except for ZLPhotoBrowser
, are using static_framework
or static_library
by default.
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, in this case, the intention is to use static_framework
or static_library
for certain libraries, while other libraries should default to use_frameworks!
.
Therefore, add the following code to the end of the Podfile:
use_frameworks!
...
# Libraries that need 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