How Componentization Boosts iOS & Android App Development Efficiency
This article summarizes a March 10 technical session on componentizing iOS and Android applications, describing the challenges of monolithic codebases, the benefits of modular architecture, communication patterns, lifecycle management, version control, CI integration, and practical lessons learned.
This article summarizes a March 10 technical session of the "Mobile Frontline" group, presented by Li Zhong (aka Silver Time) from Mogujie, focusing on componentization of iOS and Android apps.
Why componentization?
When the app was small, a single Xcode project was sufficient, but as code and team size grew, serious problems appeared: tight coupling, frequent Xib and project conflicts, and low development efficiency for business teams.
Benefits of componentization
Faster compilation because only the changed component is built.
Freedom to choose development patterns (MVC, MVVM, FRP).
Targeted QA testing.
Improved business development efficiency.
Component communication (iOS example)
Components expose URLs via MGJRouter. A component registers a pattern such as @"mgj://detail?id=:id" and handles the parameters in a block.
[MGJRouter registerURLPattern:@"mgj://detail?id=:id" toHandler:^(NSDictionary *routerParameters) {
NSNumber *id = routerParameters[@"id"];
// create and push view controller
}];The host app opens the page with [MGJRouter openURL:@"mgj://detail?id=404"]; To discover available URLs, a backend service generates header files for iOS ( .h/.m) and Java files for Android, which are imported into the projects.
Protocol‑based data exchange
For synchronous calls, a component can expose a protocol, e.g. @protocol MGJCart with + (NSInteger)orderCount;. The host registers the implementation with ModuleManager and retrieves it via classForProtocol:.
@protocol MGJCart <NSObject>
+ (NSInteger)orderCount;
@endComponent lifecycle management
Each component conforms to ModuleProtocol and implements - (BOOL)application:didFinishLaunchingWithOptions:. The shell app loads a plist that lists modules, and ModuleManager invokes the appropriate lifecycle methods.
Shell project
Components are packaged into a shell project that contains shared SDKs and base components. The shell isolates business code from the main app, reducing version‑sync issues.
Version management
All components and third‑party libraries are managed with CocoaPods (private specs). Version mismatches between the shell and main project cause build failures; the team mitigates this by centralizing version definitions and limiting pod update scope.
Continuous integration
A CI pipeline builds each component before allowing version upgrades. The pipeline also provides a web UI for selecting component versions (e.g., 0.1.8‑rc.1) and promotes stable releases after successful checks.
Resource duplication and public UI components
After splitting, duplicate resources increase bundle size. The team plans a shared UI component library that can be reused across apps.
QA highlights
Q: How are protocols handled on Android? A: Android uses a similar commanager approach. Q: How to avoid duplicate resources? A: A package‑size compression tool deduplicates and compresses images.
Conclusion
Componentization is an effective solution for large‑scale mobile apps, improving compile speed, modularity, and team productivity, while introducing new challenges in version control, CI integration, and resource management.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
