swift - 具有静态库依赖的 CocoaPod

标签 swift dependencies cocoapods

我目前正在尝试第一次创建一个包含多个依赖项的 pod。

我目前包含在我的 pod 中的 pod 如下

  • Facebook 核心
  • Facebook登录
  • Fabric
  • 推特工具包
  • Google/登录
  • 领英 swift

我的 podspec 文件如下所示

Pod::Spec.new do |s|

  s.platform     = :ios
  s.ios.deployment_target = '8.0'
  s.name         = "Socializin"
  s.version      = "0.0.1"
  s.summary      = "A short description of Socializin."
  s.requires_arc = true

  s.author       = {"MyName" => "MyMail"}
  s.homepage     = "http://EXAMPLE/Socializin"
  s.license      = { :type => "MIT", :file => "LICENSE" }
  s.source       = { :git => "", :tag => "#{s.version}"}

  s.framework    = "UIKit"
  s.dependency 'FacebookCore', '~> 0.2.0'
  s.dependency 'FacebookLogin', '~> 0.2.0'
  s.dependency 'FacebookShare', '~> 0.2.0'
  s.dependency 'Fabric', '~> 1.6.11'
  s.dependency 'TwitterKit', '~> 2.8.1'
  s.dependency 'Google/SignIn', '~> 3.0.3'
  s.dependency 'LinkedinSwift', '~> 1.7.4'

  s.source_files = "Socializin/**/*.{swift}"
  #s.resources = "Socializin/**/*.{png,jpeg,jpg,storyboard,xib}"
end

但是依赖项给我以下错误

[!] 'Pods-socializinTest' 目标具有传递依赖性,包括静态二进制文件:(/Users/x/projects/x/Examples/socializinTest/Pods/Fabric/iOS/Fabric.framework,/Users/x/projects/x/Examples/socializinTest/Pods/Google/Frameworks/GGLCore.framework, and/Users/x/projects/x/Examples/socializinTest/Pods/Google/Frameworks/GGLSignIn.framework)

有没有办法确保它确实有效?我想要做的就是创建一个 pod,它将使所有这些服务的使用变得容易,并且能够在需要时向其中添加更多服务。

最佳答案

希望您仍在寻找解决方案。
这就是我所做的:
我把Google SignIn框架放在/Dependency/GoogleDependency下
我把 TwitterKit、TwitterCore 和 Fabric 框架放在/Dependency/TwitterDependency/下

Pod::Spec.new do |s|
  s.platform     = :ios
  s.ios.deployment_target = '9.0'
  s.name         = "Socializin"
  s.version      = "0.0.1"
  s.summary      = "A short description of Socializin."
  s.requires_arc = true

  s.author       = {"MyName" => "MyMail"}
  s.homepage     = "http://EXAMPLE/Socializin"
  s.license      = { :type => "MIT", :file => "LICENSE" }
  s.source       = { :git => "", :tag => "#{s.version}"}

  s.framework    = "UIKit"
  s.dependency 'FacebookCore', '~> 0.2.0'
  s.dependency 'FacebookLogin', '~> 0.2.0'
  s.dependency 'FacebookShare', '~> 0.2.0'
  s.dependency 'LinkedinSwift', '~> 1.7.4'

  s.source_files = "Socializin/**/*.{swift}"
  #s.resources = "Socializin/**/*.{png,jpeg,jpg,storyboard,xib}"

  #----------------------------Sub Modules-----------------#
  s.subspec 'GoogleAuthentication' do |ss|
    ss.ios.deployment_target = '9.0'
    ss.source_files = 'Socializin/Dependency/GoogleDependency/**/*.{swift}'
    ss.resources = ['Socializin/Dependency/GoogleDependency/**/*.{xib,xcdatamodeld,bundle}']
    ss.vendored_frameworks = ['Socializin/Dependency/GoogleDependency/**/*.{framework}']
    ss.preserve_paths = ['Socializin/Dependency/GoogleDependency/**/*.{framework}']
    frameworkPaths = ''
    Dir.glob('Socializin/Dependency/GoogleDependency/**/*.{framework}') do |filename|
      filePath = Pathname.new(filename)
      newFilename = filePath.dirname
      if frameworkPaths != "" 
        frameworkPaths = "#{frameworkPaths} \"$(PODS_ROOT)/#{newFilename}\""
      else
        frameworkPaths = "\"$(PODS_ROOT)/#{newFilename}\""
      end
    end
    ss.xcconfig = { 
      'FRAMEWORK_SEARCH_PATHS' => frameworkPaths,
      'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Socializin/Dependency/GoogleDependency"', 
    }
    #Authentication
    # ss.dependency 'GoogleSignIn'
    ss.dependency 'GoogleToolboxForMac/NSDictionary+URLArguments'
    ss.dependency 'GoogleToolboxForMac/NSData+zlib'
  end

  s.subspec 'TwitterAuthentication' do |ss|
    ss.ios.deployment_target = '9.0'
    ss.source_files = 'Socializin/Dependency/TwitterDependency/**/*.{swift}'
    ss.resources = ['Socializin/Dependency/TwitterDependency/TwitterKit/iOS/TwitterKit.framework/*.{xib,xcdatamodeld,bundle}']
    ss.vendored_frameworks = ['Socializin/Dependency/TwitterDependency/**/*.{framework}']
    ss.preserve_paths = ['Socializin/Dependency/TwitterDependency/**/*.{framework}']
    frameworkPaths = ''
    Dir.glob('Socializin/Dependency/TwitterDependency/**/*.{framework}') do |filename|
      filePath = Pathname.new(filename)
      newFilename = filePath.dirname
      if frameworkPaths != "" 
        frameworkPaths = "#{frameworkPaths} \"$(PODS_ROOT)/#{newFilename}\""
      else
        frameworkPaths = "\"$(PODS_ROOT)/#{newFilename}\""
      end
    end
    ss.xcconfig = { 
      'FRAMEWORK_SEARCH_PATHS' => frameworkPaths,
      'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Socializin/Dependency/TwitterDependency"',
    }
    #Authentication
    # ss.dependency 'Fabric'
    # ss.dependency 'TwitterKit'
    # ss.dependency 'TwitterCore'
  end
end

关于swift - 具有静态库依赖的 CocoaPod,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42691439/

相关文章:

swift - ViewForAnnotation 未在 Swift 3 中调用

ios - 将 UIView 输出为视频流

swift - 如何在 View Controller 中以编程方式切换 View ? (Xcode,iPhone)

.net - 如何从.NET解决方案构建 'dependency tree diagram'

java - 对于 Thorntail 项目,pom.xml 中的所有依赖项 groupId 都必须是 io.thorntail?

ios - 尝试获取电话号码时不断获取 nil

Maven 组装插件 : include file without taking its path folders

macos - 如何查看已安装的 cocoa pod 的版本?

ios - CocoaPods 如何在不更新其他库的情况下安装一个新库

ios - 如何解决 Pod 安装错误?