Cocoapods 1.9.0 更新日志

谁说我不能喝 提交于 2020-03-09 18:57:07

CocoaPods 1.9 现在支持 “XCFrameworks”, “podspec支持基于配置的依赖”, “指定 schemes 的代码覆盖率”, “use_frameworks link自定义”

XCFramework Support

推荐指数:***

随着Xcode11,苹果引入的新的Bundle格.XCFramework. 这种支持多个不同的架构和平台类型的.framework捆绑到一个结构里面。 二进制依赖项也需要XCFrameworks来支持macOS Catalina中引入的新的Catalyst平台。

用法

Pod::Spec.new do |s|
  s.name         = 'ToastLib'
  s.version      = '1.0.0'

  # ...rest of attributes here

  s.vendored_frameworks = 'ButterLib.xcframework'
end

如何创建xcframework参考视频

Configuration-based dependencies for Podspecs

推荐指数:**

Podspecs也指出基于配置的依赖了

用法

Podfile修改

target 'BananaApp' do
  pod 'Toast', :configurations => ['Debug']
end

Podspec修改

Pod::Spec.new do |s|
  s.name         = 'ToastLib'
  s.version      = '1.0.0'

  # ...rest of attributes here

  s.dependency 'ButterDebugging', :configurations => ['Debug']
  s.dependency 'ErrorReportingTool', :configurations => ['Release']
end

注意目前只支持:DebugRelease

Code Coverage in Test Specs

推荐指数:***

支持code_coverage,依赖在1.7版本中引入的 scheme

用法

Pod::Spec.new do |s|
  s.name         = 'Networking'
  s.version      = '1.0.0'

  # ...rest of attributes here

  s.test_spec 'Tests' do |test_spec|
    test_spec.scheme = {
      :code_coverage => true, :environment_variables => {'FOO' => 'BAR' }
    }
  end
end

Swift Version Variants

推荐指数:*** 现在,在podspec里使用swift_versions 可以指定多个swift版本,配合Podfile里面supports_swift_version使用

用法

Podspec

Pod::Spec.new do |s|
  s.name         = 'CannonPodder'
  s.version      = '1.0.0'

  # ...rest of attributes here

  s.swift_versions = ['4.0', '5.0']
end

Podfile

target 'SampleApp' do
  supports_swift_version '< 5.0'
  pod 'CannonPodder'
end

target 'SecondApp' do
  supports_swift_version '>= 5.0'
  pod 'CannonPodder'
end

use_frameworks! Linkage Customization

推荐指数:***** 现在Swift支持static linking,CocoaPods扩展了DSL,允许指定连接包的类型。

用法

use_frameworks! :linkage => :static
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!