A Swift 4.2 VIPER Module Boilerplate Generator with predefined functions and a BaseViewProtocol.

Overview

Visits Badge Swift_Version GitHub stars GitHub issues GitHub license

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.


Are you new to VIPER Design Pattern? Want to Learn it But feel overwhelmed of all the files you have to create?

When you decide to use VIPER architecture in your project, it feels overwhelming to create new modules, because you need create at least 5 files for each. Imagine that you need to create 6 modules...We were suffering of this problem, and this is the reason why We've created this template. It's very useful for us and I hope that it be useful for you too.

Available Generator options:

  • BaseViewProtocol - A Common Functions Placeholder.
  • With Generic Functions & Shortname - Fullname filenames - check Table below for shortnames.
  • With Generic Functions - Protocols with Generic Functions ready for implementation.
  • Without Generic Functions.

UI Ready implementation.

  • Both Options With & Without Generic Functions contains a UI file ready for Implemntation.

Generated files

This template generates all files that you need to create a new VIPER module. All generated code is Swift 3.2 & Swift 4 compatible.

The Fullname dropdown will Generate full filenames with Generic Functions.

Other Dropdown Selections With OR Without Generic Functions.

File Name Acts As Description
VYourFileNameUI.swift UIView This is where your design layout should be.
CYourFileName.swift Contract This is where all your VIPER protocols should be implemented.
VYourFileName.swift View If you use Storyboard, Link this to it and ignore UI file.
IYourFileName.swift Interactor This is what will communicate with the Data Layer and Entity.
PYourFileName.swift Presenter This is what will communicate with the View and the Interactor.
EYourFileName.swift Entity This is the Entity, It's should be a String respresntation of your Model.
RYourFileName.swift Router This is where your routes to another views should be.

BaseViewProtocol Option.

File Name Acts As Description
BaseViewProtocol.swift UIViewController This where application wide UI Loaders OR TabBar should be.

How to install

Using script (easy)

Only need execute this command in terminal:

sudo swift install.swift

You should be this output message:

If all it's ok you now could find your template in Xcode.

Manual

Go to Application folder, browse to the Xcode application icon. Right-click it and choose 'Show Package Contents'. Then browse to: Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application and add "VIPER Module.xctemplate" file. Now you can find your template in Xcode.

Easy to use

VIPER diagram overview

Preview

VIPER Checklist

To get started easier, we’ve prepared a list of notes to make sure everything follows the VIPER’s design principle. We hope this will be useful to you also as we find it to be.

  • Views and view controllers receive user interactions and pass them to presenters for decision making.
  • Presenters contain the view logics and prepare content for display and reacting to user inputs.
  • Presenters should not know about the existence of all UIViews.
  • Interactors contain business logics and they should be independent of UI.
  • Entities are model objects manipulated by Interactors.
  • Wireframe is the only place to define screen navigations and their transition animations.
  • Contracts contains all my functions that I'll use for the project.

What is VIPER?

VIPER is not a framework but an approach to iOS application architecture, which stands for:

VIEW

The view consists of views and view controllers. It is responsible to receive user interactions and pass them to presenters for decision making. To keep the view simple, it shouldn’t contain any view logics. This is where to define how the view looks like, and nothing beyond this.

PRESENTER

The presenter defines the view logics, e.g. when to show a warning message or highlight a button. It is responsible to prepare content for the view to display. Whenever data is required, the presenter requests data from interactors (but not directly from the model).

INTERACTOR

The interactor mainly contains business logic, e.g. logging in the user / processing a purchase / sending a friend request. It should be independent of the UI. It only handles requests from the presenter and prepare corresponding data regardless of how the view looks like.

ENTITY

Entities are the model objects manipulated by an Interactor and only by the Interactor. It is simply a Struct. It is model orientated and therefore should not contain any business logic, Entity is not the Model, it's a represntation of the Model.

ROUTING (WIREFRAME)

Wireframe defines the routes from one screen to another. In VIPER, the responsibility for Routing is shared between the presenter and the wireframe. When the presenter receives user interactions and decided to navigate to another screen, it will use the wireframe to perform the desired navigation (to which screen and how to navigate). The wireframe can also contain transition animations.

Why VIPER?

After using VIPER, I've found it to be very beneficial in many ways. Let’s get back to the list of things we set out to accomplish when architecting our app to see if VIPER addresses them.

  • Single responsibility principles applied.
  • Easy to iterate on.
  • Collaboration friendly.
  • Separated out concerns.
  • Spec-ability.
  • Testability.

Next steps

Would you like decide what will be the next feature?

  • Create bash script to install more easy.
  • Divide Interactor protocol (Input & Output) (NEW! Version 1.1).
  • Swift 4.2 & XCode 10 (NEW! Version 1.4).
  • Create Data Layer for Interactor Implementations.
  • Create a Tutorial on how VIPER Works and how to Implement it in a real-life project.

References

Contributed

This is an open source project, so feel free to contribute.


The knowledge that I own today is because of my parents support, What I am today is because of their efforts & hardwork providing the best, Thank you Mom & Dad ❤️ .

Authors

You might also like...
A holistic approach to iOS development, inspired by Redux and MVVM
A holistic approach to iOS development, inspired by Redux and MVVM

Tempura is a holistic approach to iOS development, it borrows concepts from Redux (through Katana) and MVVM. 🎯 Installation Requirements CocoaPods Sw

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.
SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.

Articles related to this project Clean Architecture for SwiftUI Programmatic navigation in SwiftUI project Separation of Concerns in Software Design C

📖 Design Patterns implemented in Swift 5.0

Design Patterns implemented in Swift 5.0 A short cheat-sheet with Xcode 10.2 Playground (Design-Patterns.playground.zip). 🇨🇳 中文版 👷 Project started

Sample applications of iOS Design patterns written using swift.

ios-design-patterns This repo contains all my Sample applications of iOS Design patterns written using swift. Link for my Design patterns Blog : https

Swift-VIPER-Module - Xcode template for VIPER Architecture written in Swift 4
Swift-VIPER-Module - Xcode template for VIPER Architecture written in Swift 4

⚠️ Deprecated ⚠️ This library is deprecated. When you decide to use VIPER architecture in your project, it is very tired create new modules, because y

NV_MVVM-C is a template file generator. This can reduce the time taken to write the boilerplate code and create the files.
NV_MVVM-C is a template file generator. This can reduce the time taken to write the boilerplate code and create the files.

NV_MVVM-C Template, is an MVVM-C Boilerplate generator which will help you generate all the necessary files for your project architected in MVVM-C.

LOL Champions app: a small Multi-Module demo application to demonstrate modern iOS application tech-stacks with a Multi-module and MVVM architecture
LOL Champions app: a small Multi-Module demo application to demonstrate modern iOS application tech-stacks with a Multi-module and MVVM architecture

LOL Champions app: a small Multi-Module demo application to demonstrate modern iOS application tech-stacks with a Multi-module and MVVM architecture

VIPERModuleTemplate - Template of VIPER Module for Xcode
VIPERModuleTemplate - Template of VIPER Module for Xcode

Once you've decided to use a VIPER architecture in your app, you should know about the routine. For each screen/module you should create at least 6 fi

Challenge-viper-finance - Project for VIPER Architecture Dev Sprints on Devpass
Challenge-viper-finance - Project for VIPER Architecture Dev Sprints on Devpass

VIPER Challenge - Finance App 💰 Neste desafio, aplicaremos conceitos da arquite

A beautiful set of predefined colors and a set of color methods to make your iOS/OSX development life easier.
A beautiful set of predefined colors and a set of color methods to make your iOS/OSX development life easier.

Installation Drag the included Colours.h and Colours.m files into your project. They are located in the top-level directory. You can see a demo of how

Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.
Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.

ATGMediaBrowser ATGMediaBrowser is an image slide-show viewer that supports multiple predefined transition styles, and also allows the client to defin

🎚️ STDiscreteSlider – slider which allows user to choose value only from predefined set of data.
🎚️ STDiscreteSlider – slider which allows user to choose value only from predefined set of data.

STDiscreteSlider – slider which allows user to choose value only from predefined set of data. Slider may receive any types of options, you may pass set of integers or strings, or any other type. Written using SwiftUI.

The easiest Future and Promises framework in Swift. No magic. No boilerplate.

Promis The easiest Future and Promises framework in Swift. No magic. No boilerplate. Overview While starting from the Objective-C implementation of Ju

A minimalistic, thread safe, non-boilerplate and super easy to use version of Active Record on Core Data.
A minimalistic, thread safe, non-boilerplate and super easy to use version of Active Record on Core Data.

Skopelos A minimalistic, thread-safe, non-boilerplate and super easy to use version of Active Record on Core Data. Simply all you need for doing Core

Boilerplate-free mocking framework for Swift!

Cuckoo Mock your Swift objects! Introduction Cuckoo was created due to lack of a proper Swift mocking framework. We built the DSL to be very similar t

100% Swift Simple Boilerplate Free Core Data Stack. NSPersistentContainer
100% Swift Simple Boilerplate Free Core Data Stack. NSPersistentContainer

DATAStack helps you to alleviate the Core Data boilerplate. Now you can go to your AppDelegate remove all the Core Data related code and replace it wi

Template repository for quickly creating boilerplate code for a SwiftUI macOS app.
Template repository for quickly creating boilerplate code for a SwiftUI macOS app.

Sidebar App This is a template repository for quickly creating boilerplate code for a SwiftUI macOS app. License This app is released into the public

This is a template repository for quickly creating boilerplate code for a SwiftUI macOS menu bar app.
This is a template repository for quickly creating boilerplate code for a SwiftUI macOS menu bar app.

Menu Bar App This is a template repository for quickly creating boilerplate code for a SwiftUI macOS menu bar app. License This app is released into t

Crush & Lovely's iOS boilerplate

Amaro Crush & Lovely's iOS boilerplate. Changelog Say what now? We want to hit the ground running. Xcode and the iOS ecosystem don't make that easy. E

Releases(1.4)
Owner
Mohamad Kaakati
Founder / CTO @barqfleet
Mohamad Kaakati
MoneySafe - Application for tracking income and expenses and analyzing expenses. VIPER architecture, CoreData, Charts

?? MoneySafe ?? Application for tracking income and expenses and analyzing expen

Vladislav 5 Dec 27, 2022
This repository contains a detailed sample app that implements VIPER architecture in iOS using libraries and frameworks like Alamofire, AlamofireImage, PKHUD, CoreData etc.

iOS Viper Architecture: Sample App This repository contains a detailed sample app that implements VIPER architecture using libraries and frameworks li

MindOrks 653 Jan 2, 2023
A collection of iOS architectures - MVC, MVVM, MVVM+RxSwift, VIPER, RIBs and many others

ios-architecture WIP ?? ?? ?? ??️ Demystifying MVC, MVVM, VIPER, RIBs and many others A collection of simple one screen apps to showcase and discuss d

Pawel Krawiec 1.3k Jan 3, 2023
Viper Framework for iOS using Swift

Write an iOS app following VIPER architecture. But in an easy way. Viper the easy way We all know Viper is cool. But we also know that it's hard to se

Ferran Abelló 504 Dec 31, 2022
Swift Interaction with VIPER Architecture

SwiftyVIPER SwiftyVIPER allows easy use of VIPER architecture throughout your iOS application. VIPER Architecture What is VIPER? Great question! VIPER

Cody Winton 121 Jan 2, 2023
Techcareer.net Bootcamp graduation project written with VIPER, highly inspired by Getir

götür Techcareer.net iOS Bootcamp'i bitirme projesi, Getir'den yüksek miktarda i

Kemal Sanlı 9 Dec 3, 2022
Sample project using VIPER architecture

VIPER-Persons Small project using a master and detail view Demonstrates the use of the following features: VIPER architecture (https://mutualmobile.co

Sebastian Wramba 43 Feb 11, 2022
Spin aims to provide a versatile Feedback Loop implementation working with the three main reactive frameworks available in the Swift community (RxSwift, ReactiveSwift and Combine)

With the introduction of Combine and SwiftUI, we will face some transition periods in our code base. Our applications will use both Combine and a thir

Spinners 119 Dec 29, 2022
This is an example of clean architecture and MVVM pattern written in swift

Swift Clean Architecture MVVM This is an example of clean architecture and MVVM pattern written in swift First of all thanks to all of those who made

null 19 Oct 12, 2022
Stateful view controller containment for iOS and tvOS

StateViewController When creating rich view controllers, a single view controller class is often tasked with managing the appearance of many other vie

David Ask 309 Nov 29, 2022