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放置在第一位,保證在代碼編譯以前,模板代碼已經生成完畢 數據結構