top of page
SwiftCon_icon-turned_edited.png
SwiftCon_logo.png

Leonardo Cardoso

Senior iOS Engineer
Trade Republic
greg-fawson-foto.1024x1024 Kopie.jpg

Over a decade building production systems across backend, web, and mobile. Currently on the Cards team at Trade Republic, where he created SwiftMockKit, a Swift macros library that removed over 1,100 mock files and eliminated nearly 91,000 lines of generated boilerplate. Outside work, shipping indie iOS apps and AI projects at a7t.ai.

Kill Your Generated Mocks: Compile-Time Mocking with Swift Macros

Lightning talk

For years, our iOS codebase relied on Sourcery to generate mock files for testing. It worked, until we were maintaining over a thousand generated files that bloated the repo. When Apple released Swift Macros, we saw a way out.

This talk is the story of SwiftMockKit, an internal library that generates mocks at compile time with a single annotation, and how we're migrating a large fintech codebase off file-based generation. Our first batch swapped 14 protocols in a single PR; along the way we've deleted nearly 91,000 lines of committed mock boilerplate.

You will learn:
- Why file-based mock generation stops scaling, and the pain signals to watch for in your own codebase
- A migration path from Sourcery
- Where macros fall short: the protocols we couldn't handle and the compile-time costs we measured

If your test suite depends on generated mocks, you'll leave knowing exactly how to delete them.

bottom of page