Building a Modern iOS Networking Library with Swift Concurrency
Article Summary
Emre Havan from Getir rebuilt their entire iOS networking stack from scratch. The result? A modern, async-first library that eliminated memory leaks and cut boilerplate code—but not without hitting some painful Swift concurrency gotchas.
Getir's iOS team rewrote their networking library to embrace Swift's modern concurrency model, Codable support, and better testability. The article walks through their architectural decisions, from protocol design to URLSession management, revealing both wins and unexpected pitfalls along the way.
Key Takeaways
- Protocol-based request design eliminates repetitive baseURL declarations across endpoints
- Generic response wrapper preserves metadata without subclassing value types
- Convenience init pattern keeps internal protocols hidden while enabling dependency injection
- Pre-Swift 5.7 MainActor behavior caused non-deterministic UI crashes in production
- URLSession caching created memory leaks until proper invalidation in deinit
Critical Insight
The team built a scalable, unit-tested networking library with async/await that's now powering Getir's iOS app, but learned hard lessons about Swift concurrency's non-obvious behaviors.