2.0 KiB
2.0 KiB
ModelMaker
This is a command-line util to generate Swift and Objective-C models from json files.
Features
- Generate Swift models from json files.
- Generate Objective-C models from json files, and specify generic in the array.
- If you use
JSONModel
, the generated models will inherit fromJSONModel
, only for Objective-C models. - You can specify prefix and suffix for models.
- As a command-line, it is convenient to use.
Getting Started
Install
You need Swift Package Manager (as well as swift compiler) installed in your macOS, generally you are prepared if you have the latest Xcode installed.
Compile from source
> git clone https://github.com/shinancao/ModelMaker.git
> cd ModelMaker
> ./install.sh
ModelMaker will be compiled and installed into the /usr/local/bin
.
Usage
Open your terminal and run:
> modelmaker --json /Users/Shinancao/Desktop/test.json -d /Users/Shinancao/Desktop/modelFiles -t o
Please replace the params with yours.
ModelMaker supports some arguments, you could find it by:
> modelmaker -h
-h, --help:
Print this help message.
--json:
Path of json file.
-d, --dir:
Directory to the output model files.
-t, --model-type:
model type operation - o for Objective-C, s for Swift. Default is Swift.
-p, --prefix:
Set prefix for generated models. Default is nothing.
-s, --suffix:
Set suffix for generated models. Default is "Model".