Skip to content

Swift CLI tool that provides information about a Swift Package

License

Notifications You must be signed in to change notification settings

marinofelipe/swift-package-info

Repository files navigation

CI Swift Package Manager Twitter

Swift Package Info

CLI tool that provides information about a given Swift Package product, such as a measurament of its binary size impact. It's built on top of Swift Argument Parser.

Usage

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.

Examples

  • Run a full analyzes
swift-package-info --for https://github.com/ReactiveX/RxSwift -v 6.0.0 --product RxSwift
  • Check supported platforms (sub command)
swift-package-info platforms --for https://github.com/krzyzanowskim/CryptoSwift -v 1.3.8 --product CryptoSwift
  • See binary size of a local pacakge (e.g. under development framework)
swift-package-info binary-size --path ../project/my-framework

Report

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.

A custom report strategy can be passed via the report argument (check --help for supported values)

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" : {

  }
}

Installation

  • Install mint.
  • Optionally run export MINT_LINK_PATH="/usr/local/bin" to symlink it
  • Run: mint install marinofelipe/swift-package-info

Running it

  • mint run swift-package-info
  • or simply, swift-package-info in case it was symliked

Building

Build from Swift Package Manager

  • swift build in the top level directory
  • The built utility can be found in .build/debug/swift-package-info
  • Run with swift run

Running tests

Run from Xcode

  • Add the project directory to swift-package-info scheme customWorkingDirectory
  • Run the tests

Run from command line

  • swift test --build-path PROJECT_DIR

Dependencies

Binary size report

Its methodology is inspired by cocoapods-size, and thus works by comparing archives with no bitcode and ARM64 arch. Such strategy has proven to be consistent with the size added to iOS apps downloaded and installed via TestFlight.

Thanks

Special thanks to @unnamedd for sharing his experience with swift-tools-support-core and on how to build a pretty 👌 report.

Contributions

Swift Package Info is fully open and your contributions are more than welcome.