MagicIB

MagicIB 是一个命令行工具,可以从 Interface Builder 文件中快速、自动地生成 Swift 代码。

IMG_0848

Language:Swift License:MIT Latest Release Platform Compatibility Twitter

安装

$ brew install ryu0118/magicib/magicib

用法

USAGE: magicib [<project-path>] [<ib-path>] [--output-dir <output-dir>]

ARGUMENTS:
  <project-path>          The root directory of the project containing the IB
                          files you want to convert to Swift
  <ib-path>               Path of the Interface builder file you want to
                          convert to Swift

OPTIONS:
  -o, --output-dir <output-dir>
                          Output directory for files converted to Swift
  -h, --help              Show help information.

示例1

当前目录是目标 iOS 项目目录

スクリーンショット 2022-09-07 23 30 38

然后运行这个命令。

$ magicib .

スクリーンショット 2022-09-07 23 38 01

示例2

指定生成的 Swift 文件的输出目录。

スクリーンショット 2022-09-07 23 52 31

然后运行这个命令。

$ magicib . --output-dir ./output/

スクリーンショット 2022-09-07 23 52 56

示例3

从单个 storyboard 文件生成 Swift 代码。

スクリーンショット 2022-09-08 0 00 33

然后运行这个命令。

$ magicib ./Storyboards/HomeViewController.storyboard

スクリーンショット 2022-09-08 0 00 57