iOS Swift 库 - 目标具有传递依赖性 Google 分析

iOS Swift Library - target has transitive dependencies Google Analytics

我正在尝试在 podspec 的 lib 项目中安装 'Google/Analytics'。

我的项目库是使用 pod lib create 和 Swift 创建的。

这是我的 podspec:

      s.source_files = 'Pod/Classes/**/*'

      s.resource_bundles = {
        'LibPSLoginResources' => ['Pod/Resources/**/*.{xib,png,json}']
      }

      s.dependency 'FBSDKCoreKit'
      s.dependency 'FBSDKLoginKit'
      s.dependency 'Google/Analytics'
      s.dependency 'Firebase/Auth'
      s.dependency 'Firebase/Core'
      s.dependency 'Firebase/Database'

我的 PodFile:

    source 'https://github.com/CocoaPods/Specs.git'

    platform :ios, '8.0'
    inhibit_all_warnings!
    use_frameworks!

    target 'LibPSLogin_Example' do
      pod 'LibPSLogin', :path => '../'

      target 'LibPSLogin_Tests' do
        inherit! :search_paths

      end
    end

But when always run pod install I get this: target has transitive dependencies that include static binaries: (/Users/macpr/Documents/Projects/iOS/LibPSLogin/Example/Pods/Google/Libraries/libGGLAnalytics.a and /Users/macpr/Documents/Projects/iOS/LibPSLogin/Example/Pods/Google/Libraries/libGGLCore.a)

我已经尝试将这段代码放入我的 PodFile 中,但是 Google Analytics 无法通过 .swift 文件导入。

    pre_install do |installer|
        def installer.verify_no_static_framework_transitive_dependencies; end
    end

As far as I know, the library project can't import static library. But what can I do to solve this problem? Can anyone help me?

谢谢

据我所知,对于这样的库来说这是不可能的。几周前我遇到了同样的问题。

https://github.com/CocoaPods/CocoaPods/issues/6526

您可以利用 Carthage 安装纯 Swift 框架,就像我提出的 repo:https://github.com/Lucashuang0802/CocoaPodsWithCarthage

如您所知,自从 Cocoapods 1.5,可能还有 1.4,已经有可能克服臭名昭著的传递依赖问题。我的方法是现在可以使用静态框架方法,这意味着您不再需要使用#use_frameworks!在 Podfile 中,而是使用 use_modular_headers!更多信息可以在介绍 Cocoapods 1.5 的博文中找到:http://blog.cocoapods.org/CocoaPods-1.5.0/