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" : {
}
}
export MINT_LINK_PATH="/usr/local/bin" 以创建符号链接mint install marinofelipe/swift-package-infomint run swift-package-infoswift-package-info从 Swift Package Manager 构建
swift build.build/debug/swift-package-info 中找到swift run 运行从 Xcode 运行
swift-package-info scheme 的 customWorkingDirectory从命令行运行
swift test --build-path PROJECT_DIR其方法论受到 cocoapods-size 的启发,因此通过比较没有 bitcode 和 ARM64 架构的归档文件来工作。这种策略已被证明与通过 TestFlight 下载和安装的 iOS 应用所增加的大小一致。
特别感谢 @unnamedd 分享他在 swift-tools-support-core 方面的经验,以及如何构建一个漂亮的 👌 报告。
Swift Package Info 是完全开放的,非常欢迎您的贡献。