Friday, January 12, 2018

Swift Code Generation at Uber

Tuomas Artman:

For images, the tooling would run through the asset catalogs associated with each project target, find relevant images, and generate a static struct with non-null accessors for all the images. Continuous integration would run the tooling too, making sure that if anyone accidentally deleted an image from any of the asset catalogs, the revision would fail to build and the erroneous change would not land.

For localized strings, a similar struct would be constructed. Additionally, the tooling would recognize localized strings that require input variables and generate API that guarantees that the string is only accessed with the correct parameters.


The information required to generate mock classes already exists in the Swift protocol. For Uber’s use case, we set out to create tooling that would let engineers automatically generate test mocks for any protocol they wanted by simply annotating them.

Previously: Sourcery: Template-Based Code Generation for Swift.

1 Comment RSS · Twitter

Leave a Comment