Are you over feeling the pain of manually updating your Swift models after finding out (the hard way) that your dependency's JSON schema changed?
swiftgen is a code generation tool for Swift that can help alleviate this pain point by automatically generating models based on a specified schema or structure. This can help ensure that your models are always up-to-date with the latest version of the API, and can save time and effort that would otherwise be spent manually updating models.
Prerequisites:
- Go development kit of a supported version. Follow these instructions to prepare the environment.
To build and install it:
go install github.com/kevherro/swiftgen@latest
The binary will be installed in $GOPATH/bin
($HOME/go/bin
by default).
swiftgen can read a JSON schema file and convert it to Swift structs.
% swiftgen --src <json_schema_file> --dest <swift_file>
Where
json_schema_file: Path to the JSON schema file. Required.
swift_file: Path to the destination Swift file. Required.
swiftgen project structure is heavily influenced by pprof. Thanks y'all!