CI Swift Package Manager Twitter

Swift Package 信息

CLI 工具,提供给定 Swift Package 产品的信息,例如 其二进制大小影响的度量。它基于 Swift Argument Parser 构建。

用法

OVERVIEW: A tool for analyzing Swift Packages

Provides valuable information about a given Swift Package,
that can be used in your favor when deciding whether to
adopt or not a Swift Package as a dependency on your app.

USAGE: swift-package-info <subcommand>

OPTIONS:
  --version               Show the version.
  -h, --help              Show help information.

SUBCOMMANDS:
  binary-size             Estimated binary size of a Swift Package product.
  platforms               Shows platforms supported b a Package product.
  dependencies            List dependencies of a Package product.
  full-analyzes (default) All available information about a Swift Package product.

  See 'swift-package-info help <subcommand>' for detailed help.

示例

swift-package-info --for https://github.com/ReactiveX/RxSwift -v 6.0.0 --product RxSwift
swift-package-info platforms --for https://github.com/krzyzanowskim/CryptoSwift -v 1.3.8 --product CryptoSwift
swift-package-info binary-size --path ../project/my-framework

报告

swift-package-info --for https://github.com/ReactiveX/RxSwift -v 6.0.0 --product RxSwift
+------------------------------------------------+
|               Swift Package Info               |
|                                                |
|                 RxSwift, 6.0.0                 |
+--------------+---------------------------------+
| Provider     | Results                         |
+--------------+---------------------------------+
| Binary Size  | Binary size increases by 963 KB |
| Platforms    | System default                  |
| Dependencies | No third-party dependencies :)  |
+--------------+---------------------------------+
> Total of 3 providers used.

可以通过 report 参数传递自定义报告策略(查看 --help 获取支持的值)

swift-package-info --for https://github.com/ReactiveX/RxSwift -v 6.0.0 --product RxSwift --report jsonDump
{
  "binarySize" : {
    "amount" : 962560,
    "formatted" : "963 KB"
  },
  "dependencies" : [

  ],
  "platforms" : {

  }
}

安装

运行它

构建

从 Swift Package Manager 构建

运行测试

从 Xcode 运行

从命令行运行

依赖项

二进制大小报告

其方法论受到 cocoapods-size 的启发,因此通过比较没有 bitcode 和 ARM64 架构的归档文件来工作。这种策略已被证明与通过 TestFlight 下载和安装的 iOS 应用所增加的大小一致。

感谢

特别感谢 @unnamedd 分享他在 swift-tools-support-core 方面的经验,以及如何构建一个漂亮的 👌 报告。

贡献

Swift Package Info 是完全开放的,非常欢迎您的贡献。