VIPER 1.2.2

VIPER 1.2.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jun 2021
SPMSupports SPM

Maintained by incetro.



VIPER 1.2.2

  • By
  • incetro

VIPER is a framework written in Swift that makes it easy for you to build VIPER architecture more conveniently and easily

Components

  • [x] TransitionHandler
  • [x] ViewInput
  • [x] AssembliesCollector
  • [x] InteractorOutput - auxiliary protocol for Presenters
  • [x] ContentManager - auxiliary protocol for ContentManagers
  • [x] ModuleInput protocol
  • [x] ModuleOutput protocol

Usage

TransitionHandler

This component makes transition between VIPER modules

Open other module using factory

/// With 'present' option

transitionHandler?.openModule(usingFactory: factory, type: SecondModuleInput.self)
                  
   .to(preferred: TransitionStyle.present)
                  
   .then { moduleInput in
    
    moduleInput.setData(data)
}

/// Or with 'navigationController' options

transitionHandler?.openModule(usingFactory: factory, type: SecondModuleInput.self)
                  
   .to(preferred: TransitionStyle.navigationController(navigationStyle: .push))
                  
   .then { moduleInput in
    
    moduleInput.setData(data)
}

Open other module using segue identifier

transitionHandler?.performSegue(segueIdentifier)

/// Or with setup block

transitionHandler?.openModuleUsingSegue(with: segueIdentifier, to: SecondModuleInput.self) { moduleInput in
    
    moduleInput.setData(data)
}

Close your module

transitionHandler?.closeCurrentModule(true)

ViewInput

This component can help you to show different states of View

/// Start showing progress
view?.startIndication()

/// Stop progress
view?.stopIndication()

/// Show unknown error's message
view?.showError()

/// Show success view
view?.showSuccess()

/// Show the given message
view?.showMessage("Message")

/// Show the given error message
view?.showErrorMessage("Error message")

AssembliesCollector

This component facilitates the work with assemblies.

class YourModuleAssembly: CollectableAssembly {

    required init() {

    }
    
    /// Register your dependencies through Swinject.
    /// You may not call this method because 
    /// AssembliesCollector automatically call it :)
    
    func assemble(in container: Container) {
    
    }
}

Other protocols

How can you use InteractorOutput, ContentManager, ModuleInput, ModuleOutput? See the example ;)

Requirements

  • iOS 8.0+
  • Xcode 8.1, 8.2, 8.3, and 9.0
  • Swift 3.0, 3.1, 3.2, and 4.0

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

Manually

If you prefer not to use any dependency managers, you can integrate Viper into your project manually.

Embedded Framework

  • Open up Terminal, cd into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:

    $ git init
  • Add Viper as a git submodule by running the following command:

    $ git submodule add https://github.com/incetro/Viper.git
  • Open the new Viper folder, and drag the Viper.xcodeproj into the Project Navigator of your application's Xcode project.

    It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.

  • Select the Viper.xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.

  • Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.

  • In the tab bar at the top of that window, open the "General" panel.

  • Click on the + button under the "Embedded Binaries" section.

  • You will see two different Viper.xcodeproj folders each with two different versions of the Viper.framework nested inside a Products folder.

    It does not matter which Products folder you choose from, but it does matter whether you choose the top or bottom Viper.framework.

  • Select the top Viper.framework for iOS and the bottom one for OS X.

  • And that's it!

    The Viper.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.

Author

incetro, [email protected]. Inspired by ViperMcFlurry

License

VIPER is available under the MIT license. See the LICENSE file for more info.