swift-relationship-graph icon indicating copy to clipboard operation
swift-relationship-graph copied to clipboard

A simple tool to create relationships graphs for Swift codebases

This project is a small utility to create a relationship graph for protocols, classes and structs in a Swift codebase.

Examples

Alamofire

Alamofire

Haneke

Haneke

ObjectMapper

Objectmapper

Requirements

Installation

  1. Ensure your NodeJS version is 6.5.0 or later.
  2. Install Graphviz's dot command line utility.
    • On macOS you can install it with brew:
    brew install graphviz
    
  3. Install package dependencies: npm install.

Installation

Until this is published in NPM registry...

git clone [email protected]:Sumolari/swift-relationship-graph.git
cd swift-relationship-graph
npm install -g .

Usage

swift-relationship-graph <pathToJSON> [<operation>, <type...>, <pathToOutputFile>]

Where filename is the path to a SourceKitten's documentation JSON.

  • Available operations:
    • dotGraphCode
    • dotGraphPDF
    • graph (default, equivalent to dotGraphPDF)
  • Available types (multiple values allowed, comma separated):
    • protocols (default)
    • structs
    • classes

Getting SourceKitten documentation JSON

Ensure you have SourceKitten properly installed and check its usage guide.

Example:

sourcekitten doc -- -workspace Haneke.xcworkspace -scheme Haneke

Examples

Check examples folder to see some demos.

Run each .sh file to automatically download and generate the relationsip diagram of each Open Source sample project.

Todo

  • [X] Improve README
  • [X] Add proper error messages
  • [X] Add examples
  • [ ] ~~Call SourceKitten automatically~~
    • Not a priority, better add support to integrate graph generation in an Xcode plugin.
  • [ ] Improve documentation
  • [ ] Publish to NPM registry
  • [X] Add support for classes' dependency graph
  • [X] Made it -g-compatible
  • [X] Add legend
  • [ ] Add support for generating UML class-like diagrams
  • [ ] Add unit tests
  • [X] Add support for filtering by entity (tree mode)

Changelog

0.0.1

  • First version