iOS解决target has transitive dependencies that include statically linked binaries:

3,559 阅读1分钟

主工程使用use_frameworks!时,PodA 依赖 包含静态库的 PodB,pod install时报错

解决方案一:

pre_install do |installer|
  # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end

解决方案二:

PodA 的 podspec文件中加入一行s.static_framework = true,以静态库的方式引入 或者通过pre_install

除了xxx使用动态库,其它pod都使用静态库

dynamic_frameworks = ['xxx']
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

除了xxx使用静态库,其它pod都使用动态库

static_frameworks = ['xxx']
pre_install do |installer|
  installer.pod_targets.each do |pod|
    # 注意这里和上面的不同
    if static_frameworks.include?(pod.name)
      def pod.static_framework?;
        true
      end
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

参考