IBGraph

Build Status Swift 5.0

一个用于创建 .storyboard 文件图形表示的工具。

安装

使用源代码

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

使用 Homebrew (swiftbrew)

如果尚未安装,请使用 Homebrew 安装 Swiftbrew

brew install swiftbrew/tap/swiftbrew

然后输入

swift brew install IBDecodable/IBGraph

用法

您可以通过 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

生成命令

使用 default 报告器

$ ibgraph
FirstViewController -> ["SecondViewController"]

使用 dot 报告器

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

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

在线可视化此图

IBAnimatable 演示应用程序示例

或者,如果您安装了 graphviz,则可以打开预览

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

使用 online 报告器

此报告器在 https://dreampuf.github.io/GraphvizOnline/ 上打开图形

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

将图形转换为 png

首先使用 dot 报告器。

然后您可以使用 Homebrew 安装 graphviz

brew install graphviz

最后,使用 dot 命令在您的结果文件上启动转换

dot -Tpng MyStoryboards.dot -o MyStoryboards.png

或直接在 ibgraph 启动后

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

Xcode

添加一个 Run Script Phase 以将 IBGraph 与 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

要求

IBGraph 需要 Swift5.0 运行时。请满足以下至少一项要求。

配置

您可以通过从项目根目录添加 .ibgraph.yml 文件来配置 IBGraph。

描述
排除 要忽略的路径。
包含 要包含的路径。
报告器 defaultdotjsongmlgraphml 之间选择输出格式。或 online 以在默认浏览器中打开图形。
included:
  - App/Views
reporter: "dot"