Scaffolding for building apps in a clean way with VIPER architecture.
VIPER inherently has a few problems:
- Boilerplate
- Potential retain cycles due to management of many classes
- Cognitive overhead of setup
This framework aims to address those problems by providing a set of base classes to divide your app's functionality and builder object to manage the connections.
Add pod VIPERBuilder
to your Podfile
Run pod install
-
Create subclasses of
VIPERInteractor
,VIPERPresenter
andVIPERRouter
as needed -
Create a strong reference to an instance of
VIPERBuilder
with the new subclasses specified. Lazy loading in Swift will ensure that the builder object is available as soon as it is calledlazy var viperBuilder: VIPERBuilder<NewInteractor, NewPresenter, NewRouter> = { return VIPERBuilder(controller: self) }()
Note: If not all classes are needed for the implementation passing the superclass to the Builder object is supported
For a more detailed implementation, please check out the demo project included in this repo
This framework provides three base classes for the three main parts of VIPER: Interactor, Presenter, Router. Each class should contain certain pieces of code and has references to other classes for specific reasons, however these can be extended through subclassing.
- User interaction (directly and through delegation from other classes)
- Data fetching/mutation
- Presenter: should be used to update view after fetching or mutating data
- Router: Used for navigation based on actions taken
- Configuring view/view model (entity objects)
- Presenting modals/loading screens
- Controller: Presenting modals/error messages
- Interactor: Can be used as a delegate for any actions from views
- Navigation (pushing views onto UINavigationController's stack)
- Navigation controller: Used for pushing screens