Sourcery is a code generator for Swift language, built on top of Apple's own SourceKit. It extends the language abstractions to allow you to generate boilerplate code automatically.git
Sourcery是一个Swift的代码生成器,基于Apple自家的SourceKit。它经过扩展语言的抽象性,来实现了自动生成模板代码。github
在项目中建立识别的标记: swift
在项目的Build Phases增长一个Script,命名为Sourcery。 $PODS_ROOT/Sourcery/bin/sourcery --sources $SRCROOT/creams --templates $SRCROOT/creams/Infrastructure/Sourcery/AutoUnbox/AutoUnbox.stencil --output $SRCROOT/creams/Infrastructure/Sourcery/
注意请将Sourcery放置在第一位,保证在代码编译以前,模板代码已经生成完毕 数据结构