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 Objc.io, http://www.objc.io/issue-13/viper.html .
- Jofogas
- Features
- Viper files structure
- How to install vipergen
- How to generate a VIPER module with a given name?
- Developer tips
- Resources
##jofogas
- For use in the jofogas projects a jofogas template has been added and set as a default
- The path option is not required, the default will be the path from where the command is running
- Default language is objc, the template has the structure for swift but its not implemented
- Generates the module in Swift and Objective-C
- Ready to be installed as a gem https://rubygems.org/gems/VIPERGen
- Added
templates
command to know which templates are available - YAML file in each template with the information about the template (more scalable)
- Added default template
- Fully components tested
- Example project of Redbooth login with notifications
- FetchedResultsController template
- Default template in Swift
- Login template
- Integrate with XCode as a plugin (http://nshipster.com/xcode-plugins/)
.objc
+-- User Interface
| +-- View
| | +-- VIPERViewController.h
| | +-- VIPERViewController.m
| | +-- VIPERViewInterface.h
| +-- Presenter
| | +-- VIPERPresenter.h
| | +-- VIPERPresenter.m
| +-- WireFrame
| | +-- VIPERWireframe.h
| | +-- VIPERWireframe.m
+-- Module Interface
| +-- VIPERModuleInterface.h
+-- Application Logic
| +-- Interactor
| | +-- VIPERInteractor.h
| | +-- VIPERInteractor.m
| | +-- VIPERInteractorIO.h
.swift
+-- User Interface
| +-- View
| | +-- VIPERViewController.swift
| | +-- VIPERViewInterface.swift
| +-- Presenter
| | +-- VIPERPresenter.swift
| +-- WireFrame
| | +-- VIPERWireframe.swift
+-- Module Interface
| +-- VIPERModuleInterface.swift
+-- Application Logic
| +-- Interactor
| | +-- VIPERInteractor.swift
| | +-- VIPERInteractorIO.swift
This is a customized version of the original vipergen, because of this the installation process is diferent.
- To ensure that you install the latest version clone or download the repository
- Then go to the root directory of the repository and run the command to create the gem and then install it:
gem build vipergen.gemspec
sudo gem install vipergen*.gem -l
If everything were right, you should have now the vipergem command available in your system console
You have just to execute the following command
vipergen generate MyFirstViperModule
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
When the gem is updated it has to be reported to the gem repository. I followed this tutorial http://amaras-tech.co.uk/article/43/Creating_executable_gems that basically says that once you have your gem ready execute:
gem build vipergen.gemspec
gem install vipergen-0.1.gem
gem push vipergen-0.1.gem
Then you'll be asked for your credentials in order to make the update in the repo (http://guides.rubygems.org/publishing/)
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
author_email: pepibumur@gmail.com
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.
- Rspec documentation: http://rubydoc.info/gems/rspec-expectations/frames
- XCode Plugins: http://nshipster.com/xcode-plugins/
- XCodeProj gem (to modify project groups structure): https://github.com/CocoaPods/Xcodeproj
- Thor, powerful Ruby library for command line: http://whatisthor.com/