SwiftyVIPER 2.0

SwiftyVIPER 2.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Feb 2018
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by Cody Winton.



Header


Code Beat

SwiftyVIPER allows easy use of VIPER architecture thoughout your iOS application.

What is VIPER?

Great question! VIPER is a backronym which stands for:

  • View
  • Interactor
  • Presenter
  • Entity
  • Router

If all of this is totally knew for you, check out my running list of VIPER Resources

Features

  • [x] VIPER Module Templates
  • [x] VIPER Unit Test Templates
  • [x] Simple Module Initialization and Presentation
  • [x] Cocoapods Support
  • [x] Carthage Support

Requirements

  • iOS 8.0+ | tvOS 9.0+
  • Xcode 8
  • Swift 3

Installation

Manually

This is discouraged, but allowed. :D

  1. Download and drop the Source folder in your project.
  2. Congratulations!


Usage of SwiftyVIPER

Installing Templates

If you’re looking for VIPER architecture templates to use directly within Xcode, you can find these in the /Templates/VIPER folder. Open your terminal and run:

cd PATH/TO/REPO

Then, simply run this command in your terminal:

mkdir -p ~/Library/Developer/Xcode/Templates/File\ Templates
cp -R Templates/VIPER ~/Library/Developer/Xcode/Templates/File\ Templates

Adding a Module

Once you’ve installed the VIPER Templates, you’re ready to add a module. Select File > New > File or use press ⌘N to bring up the template selector. You’ll find the templates at the bottom.

Choose Module for a normal module, Module Storyboard for a normal module that interacts with Storyboards, or Module Tests for a module unit tests template.

Choice

Next, choose the Module name. We’ll go with Custom.

Name

This will create 5 files per module:

  • CustomModule.swift
  • CustomViewController.swift
  • CustomPresenter.swift
  • CustomRouter.swift
  • CustomInteractor.swift

Don’t forget to target your main app. Once you’ve added the main template, go ahead and add the Unit Test template. Make sure it’s the same name! In this case, we’d stay with Custom.

Using SwiftyVIPER

Simply add a new module using the VIPER template. Once done, simply call:

import SwiftyVIPER

CustomModule().present(from: self.viewController, style: .coverVertical, completion: nil)

The module will handle the rest, including initializing and attaching all the connections necessary for the Module to show properly.

Contribute

We would love for you to contribute to SwiftyVIPER, check the LICENSE file for more info. Pull Requests welcome!

Resources

Meta