GithubHelp home page GithubHelp logo

codytwinton / swiftyviper Goto Github PK

View Code? Open in Web Editor NEW
121.0 7.0 14.0 2.41 MB

Swift Interaction with VIPER Architecture

License: MIT License

Ruby 2.57% Swift 95.59% Objective-C 1.43% Shell 0.42%
viper-template swift swift-3 viper viper-architecture cocoapod ios tvos

swiftyviper's Introduction

SwiftyVIPER

Header


Language License Platform

Build Status Docs Percentage Code Coverage Code Beat

Pod Version Carthage Compatible

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

VIPER Architecture

What is VIPER? Great question! VIPER is a backronym which stands for:

  • View
  • Interactor
  • Presenter
  • Entity
  • Router

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

Features

  • VIPER Module Templates
  • VIPER Unit Test Templates
  • Simple Module Initialization and Presentation
  • CocoaPods Support
  • Carthage Support

Requirements

  • iOS 8.0+ | tvOS 9.0+
  • Xcode 9
  • Swift 4

Installation

CocoaPods

You can use CocoaPods to install SwiftyVIPER by adding it to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '8.0'

def shared_pods
    pod 'SwiftyVIPER', '~> 1.0'
end

target 'MyApp' do
    shared_pods
end

target 'MyAppTests' do
    shared_pods
end

To get the full benefits import SwiftyVIPER wherever you import UIKit

import UIKit
import SwiftyVIPER

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

brew update
brew install carthage

To integrate SwiftyVIPER into your Xcode project using Carthage, specify it in your Cartfile:

github "codytwinton/SwiftyVIPER" ~> 1.0

Run carthage update to build the framework and drag the built SwiftyVIPER.framework into your Xcode project.

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](Assets/Template Choice.png)

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

![Name](Assets/Template Name.png)

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

  • Cody Winton โ€“ @codytwinton
  • Distributed under the MIT license. See [LICENSE][license-url] for more information.
  • Inspired by ViperMcFlurry
  • README edited with StackEdit

swiftyviper's People

Contributors

calebkleveter avatar codytwinton avatar readmecritic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftyviper's Issues

Update to use latest Swiftlint Rules

discarded_notification_center_observer
explicit_type_interface
fatal_error_message
for_where
implicitly_unwrapped_optional
notification_center_detachment
redundant_discardable_let

cyclomatic_complexity:
  ignores_case_statements: true
line_length
  ignores_function_declarations
variable_name -> identifier_name

Missing argument for parameter 'router' in call

Thanks for your SwiftyViper.
When i make a new viper module and it display two errors, Missing argument for parameter 'router' in call and value of type 'testRouter' has no member 'view' in my testConfigurator.swift file.

[!] Unable to find a specification for `SwiftyVIPER`

When I pod install, my console display red warnings "[!] Unable to find a specification for SwiftyVIPER"

This is the content of my Podfile in a new blank project below:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'testViper' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for testViper
pod 'SwiftyVIPER'
end

Compiler Error with pod on Xcode 10 beta 5

In Router class:

open func show(from: UIViewController, embedInNavController: Bool = false, setupData: Any? = nil) {
        process(setupData: setupData)
        let view = embedInNavController ? embedInNavigationController() : _view
        from.show(view, sender: nil)
    }

Line 38 from.show(view, sender: nil)has error: Value of optional type 'UIViewController?' must be unwrapped to a value of type 'UIViewController'

Anyone else seeing this?

UPDATE: sorry I commented on wrong viper pod, please delete this

Template Updates

Ensure that templates are updated to best use Swift4 and the latest swiftlint

Question on Module file

In the module file, should the lazy var presenter and view have [unowned self] or [weak self]?

e.g.
` . private(set) lazy var presenter: MyFormMoverPresenter = { [unowned self] in
MyFormMoverPresenter(router: self.router, interactor: self.interactor)
}()

private(set) lazy var view: MyFormViewController = { [unowned self] in
	var vc = self.storyboard.viewController(MyFormViewController.self)
	vc.presenter = self.presenter
	return vc
}()`

Better README

Hey, your library is really interesting.

The only problem I found was the README.md, which lacks information.
I created this iOS Open source Readme Template so you can take a look on how to better organize.
If you want, I can help you to do it.

What are your thoughts?

Carthage installation error

Hi guys, good idea ๐Ÿ˜€ for VIPER generator

But the version of Carthage it's not available..

github "codytwinton/SwiftyVIPER" ~> 4.0

No available version for github "codytwinton/SwiftyVIPER" satisfies the requirement: ~> 4.0.0

Without version

The following build commands failed:
PhaseScriptExecution Swift\ Lint /Users/Lito/Library/Developer/Xcode/DerivedData/SwiftyVIPER-ewlkpssthmgrxzeyuoczepotiwud/Build/Intermediates/SwiftyVIPER.build/Release-appletvos/SwiftyVIPERtvOS.build/Script-6AA354C81E1783A500FB46AA.sh
(1 failure)

Last release it's 1.2.3? This version it's availavable.. not 4.0..

Thnxs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.