Skip to content

Generate a graph by reading storyboard connections.

License

Notifications You must be signed in to change notification settings

IBDecodable/IBGraph

Repository files navigation

IBGraph

Build Status Swift 5.0

A tool to create a graph representaton of your .storyboard files.

Install

Using sources

git clone https://github.com/IBDecodable/IBGraph.git
cd IBGraph
make install

Using Homebrew (swiftbrew)

If not already installed yet, install Swiftbrew with Homebrew

brew install swiftbrew/tap/swiftbrew

then type

swift brew install IBDecodable/IBGraph

Usage

You can see all description by ibgraph help

$ ibgraph help
Available commands:

   help      Display general or command-specific help
   generate  Show graph (default command)
   version   Display the current version of ibgraph

Generate command

Using default reporter

$ ibgraph
FirstViewController -> ["SecondViewController"]

Using dot reporter

$ ibgraph --reporter dot
digraph {
    0 [label = "FirstViewController"];
    1 [label = "SecondViewController"];

    0 -> 1;
}
# or ibgraph if reporter defined in configuration file

Visualize this graph online

Example on IBAnimatable demo app

or if you ave graphviz installed you can open preview

ibgraph --reporter dot | dot -Tpng | open -Wfa preview

Using online reporter

This reporter open the graph on https://dreampuf.github.io/GraphvizOnline/

$ ibgraph --reporter online
Open url https://dreampuf.github.io/GraphvizOnline/#digraph....

Convert graph to png

First use dot reporter.

Then you can install graphviz using Homebrew

brew install graphviz

And finally launch the convertion using dot command on your result file

dot -Tpng MyStoryboards.dot -o MyStoryboards.png

or directly after ibgraph launch

 ibgraph --reporter dot | dot -Tpng -o MyStoryboards.png

Xcode

Add a Run Script Phase to integrate IBGraph with Xcode

if which ibgraph >/dev/null; then
  if which dot >/dev/null; then
    ibgraph generate --reporter dot | dot -Tpng -o storyboards.png
  else
    echo "warning: dot from graphviz is not installed, check how to install here https://github.com/IBDecodable/IBGraph#convert-graph-to-png"
  fi
fi
else
  echo "warning: IBGraph not installed, download from https://github.com/IBDecodable/IBGraph"
fi

Requirements

IBGraph requires Swift5.0 runtime. Please satisfy at least one of following requirements.

Configuration

You can configure IBGraph by adding a .ibgraph.yml file from project root directory.

key description
excluded Path to ignore.
included Path to include.
reporter Choose the output format between default, dot, json, gml and graphml. Or online to open graph on default browser.
included:
  - App/Views
reporter: "dot"