Swift Interaction with VIPER Architecture

Overview

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

Comments
  • Missing argument for parameter 'router' in call

    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.

    opened by zephoon 8
  • Carthage installation error

    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

    opened by litoarias 6
  • Better README

    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?

    enhancement 
    opened by lfarah 2
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull request corrects the spelling of CocoaPods 🤓 https://github.com/CocoaPods/shared_resources/tree/master/media

    Created with cocoapods-readme.

    opened by ReadmeCritic 1
  • [!] Unable to find a specification for `SwiftyVIPER`

    [!] 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
    
    opened by zephoon 1
  • Compiler Error with pod on Xcode 10 beta 5

    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

    opened by elprl 0
  • Update to use latest Swiftlint Rules

    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
    
    enhancement 
    opened by codytwinton 0
  • Question on Module file

    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
    }()`
    
    opened by elprl 0
  • Examples of uses in UINavigationControllers and UITabBarController

    Examples of uses in UINavigationControllers and UITabBarController

    Could the example project be updated with a use case for modules in UINavigationControllers and UITabBarControllers? Also, will you be doing a Swift 4.2 update?

    bug 
    opened by elprl 3
Releases(2.0)
Owner
Cody Winton
Software Engineer @Facebook
Cody Winton
This repository contains a detailed sample app that implements VIPER architecture in iOS using libraries and frameworks like Alamofire, AlamofireImage, PKHUD, CoreData etc.

iOS Viper Architecture: Sample App This repository contains a detailed sample app that implements VIPER architecture using libraries and frameworks li

MindOrks 653 Jan 2, 2023
MoneySafe - Application for tracking income and expenses and analyzing expenses. VIPER architecture, CoreData, Charts

?? MoneySafe ?? Application for tracking income and expenses and analyzing expen

Vladislav 5 Dec 27, 2022
Sample project using VIPER architecture

VIPER-Persons Small project using a master and detail view Demonstrates the use of the following features: VIPER architecture (https://mutualmobile.co

Sebastian Wramba 43 Feb 11, 2022
Viper Framework for iOS using Swift

Write an iOS app following VIPER architecture. But in an easy way. Viper the easy way We all know Viper is cool. But we also know that it's hard to se

Ferran Abelló 504 Dec 31, 2022
A Swift 4.2 VIPER Module Boilerplate Generator with predefined functions and a BaseViewProtocol.

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Are you new to VIPER Design Pattern? Want

Mohamad Kaakati 68 Sep 29, 2022
A collection of iOS architectures - MVC, MVVM, MVVM+RxSwift, VIPER, RIBs and many others

ios-architecture WIP ?? ?? ?? ??️ Demystifying MVC, MVVM, VIPER, RIBs and many others A collection of simple one screen apps to showcase and discuss d

Pawel Krawiec 1.3k Jan 3, 2023
Techcareer.net Bootcamp graduation project written with VIPER, highly inspired by Getir

götür Techcareer.net iOS Bootcamp'i bitirme projesi, Getir'den yüksek miktarda i

Kemal Sanlı 9 Dec 3, 2022
This is an example of clean architecture and MVVM pattern written in swift

Swift Clean Architecture MVVM This is an example of clean architecture and MVVM pattern written in swift First of all thanks to all of those who made

null 19 Oct 12, 2022
Sample Code of the App Architecture Book

App Architecture iOS Application Design Patterns in Swift Welcome to the repository of the App Architecture book! This repository hosts all sample cod

objc.io 2k Dec 29, 2022
Example of Clean Architecture of iOS app using RxSwift

Clean architecture with RxSwift Contributions are welcome and highly appreciated!! You can do this by: opening an issue to discuss the current solutio

null 3.6k Dec 29, 2022
Reactant is a reactive architecture for iOS

Reactant Reactant is a foundation for rapid and safe iOS development. It allows you to cut down your development costs by improving reusability, testa

Brightify 374 Nov 22, 2022
YARCH iOS Architecture

YARCH is an architecture pattern developed primarly for iOS applications. You can ask any questions in our telegram channel. Russian version of the re

Alfa Digital 196 Jan 3, 2023
SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.

Articles related to this project Clean Architecture for SwiftUI Programmatic navigation in SwiftUI project Separation of Concerns in Software Design C

Alexey Naumov 4k Dec 31, 2022
Clean Actor Model Architecture

CAMA Eonil, 2021. CAMA is short for "Clean Actor Model Architecture". As like it says, its CA(Clean Architecture) + AM(Actor model). AM here means AM

Eonil 1 Oct 10, 2021
📖 Design Patterns implemented in Swift 5.0

Design Patterns implemented in Swift 5.0 A short cheat-sheet with Xcode 10.2 Playground (Design-Patterns.playground.zip). ???? 中文版 ?? Project started

Oktawian Chojnacki 13.9k Dec 31, 2022
Spin aims to provide a versatile Feedback Loop implementation working with the three main reactive frameworks available in the Swift community (RxSwift, ReactiveSwift and Combine)

With the introduction of Combine and SwiftUI, we will face some transition periods in our code base. Our applications will use both Combine and a thir

Spinners 119 Dec 29, 2022
Sample applications of iOS Design patterns written using swift.

ios-design-patterns This repo contains all my Sample applications of iOS Design patterns written using swift. Link for my Design patterns Blog : https

ShreeThaanu Raveendran 3 Nov 2, 2022
Swift-VIPER-Module - Xcode template for VIPER Architecture written in Swift 4

⚠️ Deprecated ⚠️ This library is deprecated. When you decide to use VIPER architecture in your project, it is very tired create new modules, because y

Juanpe Catalán 533 Nov 17, 2022
Challenge-viper-finance - Project for VIPER Architecture Dev Sprints on Devpass

VIPER Challenge - Finance App ?? Neste desafio, aplicaremos conceitos da arquite

Devpass 15 Oct 11, 2022
Simple memory game written in Swift 4 using VIPER Architecture.

Viper Memory Game Simple memory game written in Swift 4.2 using VIPER Architecture. The Memory Game is a deck of cards where the user needs to find ma

Mati 23 Jun 6, 2022