Gem to generate VIPER modules to use them in your 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 .
- Features
- Viper files structure
- How to install vipergen
- How to generate a VIPER module with a given name?
- Developer tips
- Resources
- Generates the module in Swift
- Ready to be installed as a gem https://rubygems.org/gems/vipergeng
- 날짜 포맷을 바꿈.
- g command 추가.
- generate or g 사용시 --path 인자를 지정하지 않으면 현재 폴더에 생성하도록 수정
- g/generate command에 --base 추가. base에는 ViewController의 base class를 지정한다. 디폴트값은 UIViewController이다.
- ViewController 소스에 viewWill/DidAppear, viewWill/DidDisappear 추가
- Swift/Objc 템플릿 코드 수정.
- ViewController 코드에 코멘트로 샘플 코드 추가.
.swift
+-- DataManager
| +-- VIPERDataManager.swift
+-- Interactor
| +-- VIPERInteractor.swift
+-- Presenter
| +-- VIPERPresenter.swift
+-- ViewController
| +-- VIPERViewController.swift
+-- WireFrame
| +-- VIPERWireFrame.swift
+-- Protocols
| +-- VIPERProtocols.swiftYou can install it easily as using the gem. With ruby installed in your OSX execute:
sudo gem install vipergengIf everything were right, you should have now the vipergeng command available in your system console
You have just to execute the following command
--path 지정을 하지 않으면 현재 폴더에 생성.
vipergeng generate MyFirstViperModule --path=~/myproject/sharedor
vipergeng g MyFirstViperModuleAnother example:
vipergeng generate MySecondViperModule --path=~/myproject/shared --author='My Name' --company='My Company' --project='project name --base=MyBaseViewController'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 vipergeng.gemspec
gem install vipergeng-0.1.gem
gem push vipergeng-0.1.gemThen 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
templateswith the name of your template - You'll have to create inside the templates in Swift (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: [email protected]
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.
- https://www.objc.io/issues/13-architecture/viper/
- https://swifting.io/blog/2016/03/07/8-viper-to-be-or-not-to-be/
- 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/
- Cocoa Design Patterns: https://developer.apple.com/legacy/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html
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, [email protected] . You can use the issues Github page too
