Introduction to RIBs
RIBs is an innovative cross-platform architecture framework powering many mobile applications at Uber. The name "RIBs" represents its core components - Router, Interactor, and Builder. It's specially designed for mobile applications with large teams and complex application states.
Key Features of RIBs
-
Cross-Platform Uniformity: RIBs enable a shared architecture across both iOS and Android platforms. This consistency allows teams to review business logic seamlessly, regardless of the platform.
-
Testability and Isolation: The architecture emphasizes ease of unit testing by isolating class responsibilities. Each RIB class, such as routing or view logic, is independent, making it simpler to test and understand.
-
Developer Productivity Tools: RIBs come equipped with tools like IDE code generation, memory leak detection, and static analysis. These tools streamline the development process, boosting productivity for both small and large development teams.
-
Scalability: The architecture has been tested to support a large codebase managed by hundreds of engineers, ensuring smooth scalability.
Documentation and Getting Started
For those interested in diving deeper into RIBs, comprehensive documentation is available. This documentation covers fundamental aspects like RIBs' structure and typical use cases. Moreover, practical tutorials offer hands-on experience with the architecture. Uber also shares the story behind RIBs' creation through a blog post and a detailed video on its architecture.
Comparison with MV*/VIPER
While architectural patterns like MVC, MVP, and VIPER are familiar, RIBs differentiate itself as a framework with:
-
Business Logic-Driven Architecture: Unlike traditional patterns where the view tree often dictates structure, RIBs prioritize business logic, allowing an app to function correctly even without a corresponding view.
-
Decoupled Logic and View: By separating business logic from the view hierarchy, RIBs maintain a clean architecture, facilitating easier layout management, animations, and transitions.
-
Cross-Platform Harmony and Tooling: RIBs ensure iOS and Android versions remain in sync while offering tools for easier large-scale adoption. Dependency Injection (DI) and Reactive Extensions (Rx) are at the core of its state management philosophy.
Usage and Installation
To use RIBs, developers can clone the repository and integrate it through their preferred method.
Android Integration
For Android, add the following to your build.gradle
to set up RIBs:
dependencies {
annotationProcessor 'com.uber.rib:rib-compiler-test:0.16.3'
implementation 'com.uber.rib:rib-android:0.16.3'
testImplementation 'com.uber.rib:rib-test:0.16.3'
}
Additional extension packages support Kotlin, Jetpack Compose, and Coroutines.
iOS Integration
CocoaPods
Integrate RIBs by adding this to the Podfile
:
pod 'RIBs', '~> 0.9'
Carthage
Add the following to the Cartfile
for Carthage support:
github "uber/RIBs" ~> 0.9
Related Projects
Uber offers several related open-source projects:
- Needle: Swift dependency injection framework.
- Motif: Simplified APIs for nested scopes.
- Swift Concurrency: Concurrency utilities inspired by Java's concurrent package.
- Swift Abstract Class: Safe abstract class development tools for Swift.
- Swift Common: Common libraries for Swift projects.
License
RIBs is distributed under the Apache License 2.0, ensuring it's free to use with proper attribution and compliance with license terms.