一个基于模板的 Swift 项目生成器。
克隆或下载该仓库并运行
git clone https://github.com/BinaryBirds/swift-template.git
cd swift-template
make install
帮助
swift run swift-template-cli --help
使用 Git 仓库安装一个新模板
swift template install <git-url-of-the-template> [-g]
# install local template
swift template install https://github.com/corekit/viper-module-template
# install global template
swift template install https://github.com/feathercms/feather-module-template -g
更新所有模板,包括本地和全局模板
swift template update
列出可用的模板
swift template list
移除模板
swift template remove [template-name]
创建一个空的模板项目仓库
swift template create [template-name] [-g]
基于模板生成一个新的模块
swift template generate [name] --use [template-name] --output [path]
# examples
swift template generate MyModule --use viper-module
swift template generate MyModule --use viper-module --output ~/
swift template generate MyModule -u viper-module -o ~/
模板可以存储在本地或全局的 .swift-template
目录中。 本地模板从当前工作目录加载,全局模板从用户主文件夹加载。 系统将优先选择本地模板(具有相同名称),而不是全局模板。
你可以在模板中使用以下参数(甚至在文件名中)
name - 给定的模块名称
Name - 给定的模块名称(首字母大写)
NAME - 给定的模块名称(大写)
project - 基于 .xcodeproj
或 .xcworkspace
名称或输入名称
author - 基于 Git 配置的用户名
date - 当前日期,本地短格式
例如: {name} -> MyModule