Getting Started with iOS App Modularization: Extracting Catalog
Article Summary
Tokopedia's iOS team tackled a common scaling problem: how do you break apart a monolithic app without creating circular dependency chaos?
This hands-on tutorial from Tokopedia Engineering walks through extracting a Catalog feature into its own framework. It's part 2 of a modularization series that shows the practical steps, not just theory.
Key Takeaways
- Create separate frameworks and configure dependencies using Xcode targets
- Use Router abstraction pattern to prevent circular dependencies between modules
- Fix bundle loading issues with Bundle(for: Self.self) for XIB files
- Make classes public and adjust ACL for cross-module access
- Navigation works without tight coupling between feature modules
A Router abstraction layer lets iOS features navigate between modules without creating circular dependencies or tight coupling.
About This Article
When Arya Surya's team tried to extract the Catalog framework, they hit a circular dependency problem. Product Detail Page needed to import Catalog, but Catalog also imported Product Detail. This created a dependency loop they couldn't solve.
Tokopedia Engineering added a Router abstraction pattern to the Shared framework. This let modules navigate to other parts of the app without importing them directly. Instead, route handlers defined in SceneDelegate handled the navigation, keeping the destination frameworks separate from the source modules.
The modularization approach worked. Catalog and Shared frameworks were successfully extracted into separate Xcode targets. The app kept working, navigation between modules stayed smooth, and there were no tight coupling issues or build failures.