Template to generate VIPER classes on Xcode. Junior-friendly version of the template. Protocols are defined at the top of classes to use them more effectively.
VIPER is a backronym for View, Interactor, Presenter, Entity and Router. It’s basically an approach that implements the Single Responsibility Principle to create a cleaner and more modular structure for your iOS project. You can learn more about it in this blog post.
- Download VIPER Template or clone the project
- Copy the
Design Pattern
folder to~/Library/Developer/Xcode/Templates/File Templates/
or create a symbolic link to that folder. - Add the StoryboardLoadable protocol extension and the UIStoryboard extension to your project.
- You can find
required base files
for your project underextensions folder and commons folder
.
- Start Xcode and create a new group for your VIPER module
- Create a new file (
File > New > File
or⌘N
) - Choose
Design Pattern
andVIPER
- Type in the name of the module you want to create
- Not required: To create Xcode groups, remove the references to the newly created files and add them back to the project
Interactor
Presenter
ViewController
(AKA View)Router
ViewController.storyboard