VIPERModuleTemplate - Template of VIPER Module for Xcode

Overview

Swift_Version GitHub stars GitHub issues GitHub license Awesome

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 files. Imagine that you need to create 10 modules. To avoid this boring work you can use this template which helps you to generate a compete module. It's very useful for me, and I hope it can be useful for you too.

Generated files

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

File Name Acts As Description
ModuleNameViewController.swift View UIViewController of your module.
ModuleNameInteractor.swift Interactor It's for communication with the Data Layer.
ModuleNamePresenter.swift Presenter It's for communication with the View and the Interactor.
ModuleNameRouter.swift Router It's for routing to other modules.
ModuleNameViewController.xib ViewControllerXib If you use xibs, you can use it for layout.
ModuleNameAssembly.swift Assembly It's an assembly, to build a module.
ModuleNameModuleAPI.swift API It's an API, a file with all protocols of your module

How to install

Using script (easy)

Execute this command in the terminal:

sudo swift install.swift

You should see this output message:

✅ VIPER Template successfully installed.

If it's ok, you could see your template in the Xcode.

Manual installation

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

Easy to use

VIPER Diagram overview

Preview

VIPER Checklist

To get started easier, we’ve prepared a checklist to make sure that everything follows the VIPER’s design principle. We hope, this list will be useful for you as it is for us.

  • Views and view controllers receive user interactions and pass them to presenters for decision making.
  • Presenters contain the view's logic and prepare content for display and reacting to user inputs.
  • Presenters should not know about the existence of all UIViewControllers.
  • Interactors contain business' logic and they should be independent of UI.

What is VIPER?

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

VIEW

View controller. 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's logic. This is where to define how the view looks like, and nothing beyond this.

PRESENTER

The presenter defines the view's logic, 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 prepares corresponding data regardless of how the view looks like.

ROUTER

Router 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.

ASSEMBLY

Assembly builds the modules with input params and links all layers. Should connect Presenter with View, Router and Interactor, Interactor with Presenter, View with Presenter. Should setup input data of module and can return module Input if needed.

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 to decide what the next feature will be?

  • Storyboard support
  • Separated iPhone & iPad UIs

References

Contribute

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


Authors

You might also like...
ViperC - Xcode template for VIPER Architecture for both Objective-C and Swift.
ViperC - Xcode template for VIPER Architecture for both Objective-C and Swift.

ViperC Xcode template for VIPER Architecture for both Objective-C and Swift. ViperC creates modules for you when you want to use VIPER architecture in

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

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

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

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

Use this template as a starting point for any Swift 5 module that you want other people to include in their projects

Swift 5 Module Template Use this template as a starting point for any Swift 5 mo

LinkedLog is a Xcode plugin that includes a Xcode PCH header file template that adds the macros `LLog` and `LLogF` and parses their output to link from the console to the corresponding file and line.
LinkedLog is a Xcode plugin that includes a Xcode PCH header file template that adds the macros `LLog` and `LLogF` and parses their output to link from the console to the corresponding file and line.

LinkedLog Xcode Plugin LinkedLog is a Xcode plugin that includes a Xcode PCH file template that adds the macros LLog and LLogF. The LLog macro will wo

XCode Preview template for UIkit based project.
XCode Preview template for UIkit based project.

SwiftPreview XCode Preview template for UIkit based project. Support custom file template class inherit from UIView and UIViewController. How to use?

Easily integrate Credit Card payments module in iOS App. Swift 4.0
Easily integrate Credit Card payments module in iOS App. Swift 4.0

MFCard Buy me a coffee MFCard is an awesome looking Credit Card input & validation control. Written in Swift 3. YOoo, Now MFCard is on Swift 5. Swift

 A Swift material design UI module which paints over the parent view when the switch is on.
A Swift material design UI module which paints over the parent view when the switch is on.

A Swift material design UI module which paints over the parent view when the switch is on. We specialize in the designing and coding of c

:octocat: AdaptiveController is a 'Progressive Reduction' Swift UI module for adding custom states to Native or Custom iOS UI elements. Swift UI component by @Ramotion
:octocat: AdaptiveController is a 'Progressive Reduction' Swift UI module for adding custom states to Native or Custom iOS UI elements. Swift UI component by @Ramotion

ADAPTIVE TAB BAR 'Progressive Reduction' module for adding custom states to Native or Custom UI elements. We specialize in the designing and coding of

RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion
RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion

ANIMATED TAB BAR Swift UI module library for adding animation to iOS tabbar items and icons.

React Native FlyBuy module. Supports Core, Pickup, Notify, and Presence Native SDK APIs.

The FlyBuy cloud service and mobile SDK enables developers to add FlyBuy functionality directly into their react native apps for a full white label im

Swift tool to generate Module Interfaces for Swift projects.

ModuleInterface Swift tool to generate Module Interfaces for Swift projects. What is a Module Interface A Module Interface is what we commonly get usi

Spika is universal chat module with backend, web, ios and Android client.
Spika is universal chat module with backend, web, ios and Android client.

Spika Spika is messenger module for Web/iOS/Android with backend. You can include messenger feature to your app or service with minimum code. For deta

A Swift material design UI module which paints over the parent view when the switch is on.
A Swift material design UI module which paints over the parent view when the switch is on.

:octocat: 🎚 RAMPaperSwitch is a Swift material design UI module which paints over the parent view when the switch is turned on. iOS library by @Ramotion

A Swift Popup Module help you popup your custom view easily
A Swift Popup Module help you popup your custom view easily

JFPopup JFPopup is a Swift Module help you popup your custom view easily. Support 3 way to popup, Drawer, Dialog and BottomSheet. Example To run the e

A ReactNative module for icloud operation

react-native-cloud-store A ReactNative module for cloud operation (currently only support icloud dirve) Developing, use at your risk, issue and PR is

Swift wrapper for PuLP module.

SwiftPuLP Wraps Python Linear Programming PuLP module. Requirements Requires PuLP to be installed, and may require PYTHON_LIBRARY environment variable

A Swift package for parsing Clang module map files

Clangler is a Swift package used to parse Clang module map files into an abstract syntax tree (AST) representation. Once parsed, you can inspect or manipulate the nodes in the file, then generate and save a new file reflecting your changes.

Comments
  • Misspelling words in README

    Misspelling words in README

    Hi, awesome work! This for sure makes it easier to start with VIPER. I love it.

    I read your README.

    Some are: shound, compete, inpurt, Presener

    If you don't mind, I could open a PR for this.

    opened by abrahamduran 2
Owner
Bogdan Evsenev
 Swift 💻 ... 🎧
Bogdan Evsenev
ViperC - Xcode template for VIPER Architecture for both Objective-C and Swift.

ViperC Xcode template for VIPER Architecture for both Objective-C and Swift. ViperC creates modules for you when you want to use VIPER architecture in

Abdullah Selek 79 Nov 2, 2022
Awesome-xcode-scripts - A curated list of useful xcode scripts 📝 .

Awesome Xcode Scripts A curated list of useful Xcode scripts ?? . Content How to Setup Scripts Build Number Auto-Increment Script Build Number Auto-In

Aashish Tamsya 110 Dec 26, 2022
Synx - A command-line tool that reorganizes your Xcode project folder to match your Xcode groups

A command-line tool that reorganizes your Xcode project folder to match your Xcode groups. Xcode Finder Installation $ gem install synx Usage Basic ⚠

Venmo 6.1k Jan 2, 2023
Swift-project-template - 🍪 Easily generate Swift projects with Cookiecutter

swift-project-template ?? Cookiecutter template for Swift iOS projects. Features: Xcode 11 and Swift 5.0 support AppCode support Custom project struct

Artem Novichkov 86 Jul 8, 2022
XcodeCodeSnippets - Code snippets for Xcode.

XcodeCodeSnippets A set of snippets for Xcode. Requirements Xcode 7.3.1 or later. Installation To install or update the snippets you need: Quit Xcode

Ivan Smetanin 33 Oct 14, 2022
Xcode-developer-disk-image-all-platforms - A repo which shares all developer disk images for iOS, tvOS, watchOS

Disclaimer: The available resources and files from this repo are uploaded from many contributors. The files are unverified, untested, and could have n

Hai K 253 Dec 21, 2022
Swift package to interact with Xcode Code Snippets in a type-safe manner

XCSnippets Swift package to provide type-safe interaction with (user-defined) Xcode Code Snippets Overview import XCSnippets let directory = Persiste

Marco Eidinger 4 Oct 11, 2022
CodeEditTextView - An Xcode-inspired code editor view written in Swift powered by tree-sitter for CodeEdit

An Xcode-inspired code editor view written in Swift powered by tree-sitter for CodeEdit. Features include syntax highlighting (based

CodeEdit 243 Jan 8, 2023
Swift package to interact with Xcode Code Snippets in a type-safe manner

XCSnippets Swift package to provide type-safe interaction with (user-defined) Xcode Code Snippets Overview import XCSnippets let directory = Persiste

Marco Eidinger 3 Jun 24, 2022
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

Juanpe Catalán 533 Nov 17, 2022