https://luccifer.github.io/ramba/
-
Initialize Generamba in your project's folder and install templates from this repo
-
open terminal and execute this in the same project's folder:
$ generamba gen Module swifty_viper
The new VIPER Module/Submodule(whatever) will be generated in your project's folder with structure:
Module
├── View
│ └── ModuleViewController.swift
├── Presenter
│ └── ModulePresenter.swift
├── Interactor
│ └── ModuleInteractor.swift
├── Router
│ └── ModuleRouter.swift
├── Configurator
│ ├── ModuleConfigurator.swift
│ └── ModuleInitializer.swift
└── Protocols
└── ModuleProtocols.swift
generamba gen Test swifty_viper
import UIKit
class TestViewController: UIViewController, TestViewInput {
var output: TestViewOutput!
// MARK: Life cycle
override func viewDidLoad() {
super.viewDidLoad()
TestModuleConfigurator().configureModuleForViewInput(self)
output.viewIsReady()
}
// MARK: TestViewInput
func setupInitialState() {
}
}
class TestPresenter: TestModuleInput, TestViewOutput, TestInteractorOutput{
weak var view: TestViewInput!
var interactor: TestInteractorInput!
var router: TestRouterInput!
func viewIsReady() {
}
}
class TestInteractor: TestInteractorInput {
weak var output: TestInteractorOutput!
}
import UIKit
class TestRouter: TestRouterInput {
weak var view: UIViewController?
}
import UIKit
class TestModuleConfigurator {
func configureModuleForViewInput<UIViewController>(_ viewInput: UIViewController) {
if let viewController = viewInput as? TestViewController {
configure(viewController)
}
}
private func configure(_ viewController: TestViewController) {
let router = TestRouter()
router.view = viewController
let presenter = TestPresenter()
presenter.view = viewController
presenter.router = router
let interactor = TestInteractor()
interactor.output = presenter
presenter.interactor = interactor
viewController.output = presenter
}
}
import UIKit
class TestModuleInitializer: NSObject {
//Connect with object on storyboard
@IBOutlet weak var viewController: TestViewController!
override func awakeFromNib() {
let configurator = TestModuleConfigurator()
configurator.configureModuleForViewInput(viewController)
}
}
protocol TestViewInput: class {
func setupInitialState()
}
protocol TestViewOutput {
func viewIsReady()
}
protocol TestModuleInput: class {
}
protocol TestInteractorInput {
}
protocol TestInteractorOutput: class {
}
protocol TestRouterInput {
}
Russian Federation, Moscow, 2017 Karpushkin G.A