Swift 3.0 compliant VIPER architecture based on the post about VIPER. It saves time in the implementation generating the controllers and adding interactions between them (in Swift or Objective-C)

gem install vipergen-xctestable -v 0.3.1


Viper Module Generator

Code Climate Build Status Test Coverage Dependency Status


Gem to generate VIPER modules to use them in your Objective-C/Swift projects The implementation scheme returned by this generator is hardly inspired in the example and post of, .


Changelog 0.1.6

  • Added templates command to know which templates are available
  • YAML file in each template with the information about the template (more scalable)

Changelog 0.1

  • Added default template
  • Fully components tested

Changelog 0.2.3

  • VIPER Example using the Twitter API
  • Default template implemented in Swift

Expected in version 0.3

Viper files structure

+-- DataManager
|   +-- VIPERDataManager.h
|   +-- VIPERDataManager.m
+-- Interactor
|   +-- VIPERInteractor.h
|   +-- VIPERInteractor.m
|   +-- VIPERInteractorSpec.m
+-- Presenter
|   +-- VIPERPresenter.h
|   +-- VIPERPresenter.m
|   +-- VIPERPresenterSpec.m
+-- ViewController
|   +-- VIPERViewController.h
|   +-- VIPERViewController.m
|   +-- VIPERViewControllerSpec.m
+-- WireFrame
|   +-- VIPERWireFrame.h
|   +-- VIPERWireFrame.m
+-- Protocols
|   +-- VIPERProtocols.h
+-- DataManager
|   +-- VIPERDataManager.swift
+-- Interactor
|   +-- VIPERInteractor.swift
|   +-- VIPERInteractorTests.swift
+-- Presenter
|   +-- VIPERPresenter.swift
|   +-- VIPERPresenterTests.swift
+-- View
|   +-- VIPERView.swift
|   +-- VIPERViewTests.swift
+-- WireFrame
|   +-- VIPERWireFrame.swift
+-- Protocols
|   +-- VIPERProtocols.swift

How to install vipergen ?

You can install it easily as using the gem. With ruby installed in your OSX execute:

sudo gem install vipergen-xctestable

If everything were right, you should have now the vipergem command available in your system console

How to generate a VIPER module with a given name?

You have just to execute the following command

vipergen generate MyFirstViperModule --path=~/myproject/shared

And then the files structure will be automatically created. Don't forget to add this folder to your project dragging it into the XCode/Appcode inspector

What options are available in generator?

You have just to execute the following command

vipergen help generate

And then you will see all options available


vipergen-xctestable generate <Module_Name> --path=<Path> --language=swift --author='michal' --template=testable --swift-module <MY_Project>

How can I try the demo project?

  1. Clone the repo git clone
  2. Move into the repo folder and update the git submodules git sumodule update --init
  3. In the folder VIPERGenDemo install the pods pod install
  4. Open the project from the VIPERGenDemo.xcworkspace file
  5. Enjoy it!

Developer tips

Update the gem

When the gem is updated it has to be reported to the gem repository. I followed this tutorial that basically says that once you have your gem ready execute:

gem build vipergen.gemspec
gem install vipergen-xctestable-0.3.0.gem
gem push vipergen-xctestable-0.3.0.gem

Then you'll be asked for your credentials in order to make the update in the repo (

Add a new template

Are you interested in VIPER and you would like to contribute with this gem adding new templates? Feel free to do it. It's pretty easy. You've just to:

  • Create a folder inside templates with the name of your template
  • You'll have to create inside the templates in both languages, Swift and Objective-C (get inspired from existing templates)
  • Use the word VIPER where you want the name to be replaced in.
  • Remember to add the file viperspec.yml with the description of your template as below:
author: pepi
template_description: Default template with the simplest structure using VIPER
updated_at: 2014-08-24
  • Report it as a PR in this repo updating the gem version in Gemspec.

Available Templates

  • default by pepimbur
  • testable by wojtysim (includes Spec file templates for Interactor, Presenter and View)
  • xctestable by hhtopcu (Swift 3.0 compliant and XCTest copmliant)



If you have any doubt about the gem or even if you want to make any suggestion you can do it directly to my email address, . You can use the issues Github page too