A collection of iOS architectures - MVC, MVVM, MVVM+RxSwift, VIPER, RIBs and many others

Overview

ios-architecture

WIP

👷 🧱 🧰 🛠️
Demystifying MVC, MVVM, VIPER, RIBs and many others
A collection of simple one screen apps to showcase and discuss different architectural approaches in iOS

last commit open issues swift version platform license
Built with ❤︎ by Pawel Krawiec


Apps

Multi-screen examples Single screen examples
app-ui app-ui

Architectures

This repository hosts each sample app in separate directory.

Click the title of example to see detailed README information about specific architecture.

Multiple screens app examples

🔒 ** If you want to login, use username iostest and password test.**

If you're a themoviedb user, please use your own account and API key!

Example Description
tmdb-mvvm-rxswift-pure Uses RxSwift and observables as binding mechanism between ViewController and ViewModel. Also, it uses simple navigator pattern for transitions between screens. (README in progress)

Single screen app examples

The purpose of having examples with single page applications is highlighting connection between view code and business logic code.

Example Description
mvc Standard MVC pattern recommended by Apple. Uses composition design pattern to make ViewController smaller. (README in progress)
mvp Standard MVP pattern. (README in progress)
mvvm-rxswift-pure Uses RxSwift and observables as binding mechanism between ViewController and ViewModel.
mvvm-rxswift-functions-subjects-observables Uses RxSwift and observables as outputs from ViewModel. ViewModel inputs are defined as subjects wrapped in functions.
mvvm-rxswift-subjects-observables Uses RxSwift with observables as ViewModel outputs and subjects as ViewModel inputs.
mvvm-closures Binds ViewController and ViewModel using closures and swift functions (README in progress)
rxfeedback-mvc Uses RxFeedback in MVC architecture (README in progress)
viper Uses VIPER architecture (README in progress)

Examples in progress

Example Description
reactorkit In Progress
mvvm+rxfeedback In Progress
mvvm-reactive-swift In Progress
reswift In Progress
viper-rxswift In Progress
ribs In Progress

Sample apps

Apps in this repository are split into 2 groups - single screen and multiscreen.

Simple one screen apps aim to be simple enough that you can understand crucial bits about given architecture (i.e. bindings between ViewModel and ViewController in MVVM examples). However, some other architectures require more complexity (i.e. RIBs architecture) and this is the reason of having multiscreen examples in this project.

Single screen app

Single screen app is a simple list of repositories fetched from GitHub and a text field that makes queries for new data.

Multiscreen app

Multiscreen app is a simple themoviedb client. It lets user to authenticate, view popular movies/tv shows or actors and see details about each movie. Also, it has a search screen that allows you to browse movies or actors.

Open in Xcode

Clone the repository:

git clone [email protected]:tailec/ios-architecture.git

Go to example directory, for example:

cd mvvm-pure-swift

Install pods:

pod install

Note: Some of the examples don't use external libraries so pod install is not required.

Licence

MIT.

You might also like...
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

Stateful view controller containment for iOS and tvOS
Stateful view controller containment for iOS and tvOS

StateViewController When creating rich view controllers, a single view controller class is often tasked with managing the appearance of many other vie

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.
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

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

YARCH iOS Architecture
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

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

iOS architectures - MVC, MVP, MVVM, MVVM-C, ReactorKit, VIPER, Clean Architecture
iOS architectures - MVC, MVP, MVVM, MVVM-C, ReactorKit, VIPER, Clean Architecture

iOS architectures - MVC, MVP, MVVM, MVVM-C, ReactorKit, VIPER, Clean Architecture, RIBs; Repository Pattern, Rxflow, Swinject, Tuist, Xcodegen, Cocoapods, SPM, Carthage + Rome

Carthage cache for S3, Minio, Ceph, Google Storage, Artifactory and many others
Carthage cache for S3, Minio, Ceph, Google Storage, Artifactory and many others

Rome Rome is a tool that allows developers on Apple platforms to use: Amazon's S3 Minio Ceph other S3 compatible object stores or/and a local folder y

ModernRIBs is recreated by removing additional dependencies such as RxSwift from Uber's RIBs.
ModernRIBs is recreated by removing additional dependencies such as RxSwift from Uber's RIBs.

ModernRIBs is recreated by removing additional dependencies such as RxSwift from Uber's RIBs. Only Combine was used. All features provided by RIBs can

Swift-flows - Simplistic hot and cold flow-based reactive observer pattern for Swift… ideal for MVVM architectures

SwiftFlows Simplistic hot and cold flow-based reactive observer pattern for Swif

Boardy - Boardy serves as a digital bulletin board on iOS platforms built for high schoolers to share and view information from others in a convenient manner.

Boardy Boardy serves as a lightweight digital bulletin board on iOS platforms built for high schoolers to share and view information from others in a

Swift-VIPER-Module - Xcode template for VIPER Architecture written in Swift 4
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

Challenge-viper-finance - Project for VIPER Architecture Dev Sprints on Devpass
Challenge-viper-finance - Project for VIPER Architecture Dev Sprints on Devpass

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

MMVMi: A Validation Model for MVC and MVVM Design Patterns in iOS Applications

MMVMi MMVMi: A Validation Model for MVC and MVVM Design Patterns in iOS Applications Motivation Design patterns have gained popularity as they provide

Realm RxSwift - This application was written in order to use Realm, RxSwift frameworks in real example

Realm_RxSwift This simple app was written to introduce basic operations of some

Bill splitting and tip calculating app, build with UIKit and MVC pattern.
Bill splitting and tip calculating app, build with UIKit and MVC pattern.

Split Check Bill splitting and tip calculating app, build with UIKit and MVC pattern. Features Enter bill total with number pad. Select tip % and betw

Quizzler - iOS App Design Pattern(MVC) and Code Structuring

Quizzler iOS App Design Pattern(MVC) and Code Structuring What you will learn Ho

Easy quiz just for reviewing structures and MVC
Easy quiz just for reviewing structures and MVC

Quizzler Our Goal The goal of this tutorial is to take you one step further in your journey of becoming an app developer. We are going to introduce yo

Comments
  • Code clean up

    Code clean up

    I removed the reposViewModel variable from:

    • func reposViewModel(_ reposViewModel: ReposViewModel, isLoading: Bool)
    • func reposViewModel(_ reposViewModel: ReposViewModel, didReceiveRepos repos:)
    • func reposViewModel(_ reposViewModel: ReposViewModel, didSelectId id: Int)

    Delegate methods

    opened by amadeu01 4
  • Question: ViewModel transform(input:) -> SearchViewModel.Output

    Question: ViewModel transform(input:) -> SearchViewModel.Output

    Could you explain more about this implementation.

    func transform(input: SearchViewModel.Input) -> SearchViewModel.Output {

    I could not understand well. The ViewModel is some sort of pipeline that for an input it generates one output?

    question 
    opened by amadeu01 1
  • Error when Building after install/ update pods

    Error when Building after install/ update pods

    Hi, I have problem when I want to build the RXswift project in this Repository. I had cloned this repository and installed / updated the pods. When I build the project, those are some error occurred. The error is: Static member 'load' cannot be used on instance of type 'AtomicInt' What should I do to fix the error?

    opened by fauzibinfaisal 0
  • mvvm-delegates is not MVVM, actually that is MVP.

    mvvm-delegates is not MVVM, actually that is MVP.

    Hi, @tailec

    ViewModel has a reference of abstracted ViewController as Delegate in mvvm-delegation. It means that is not MVVM, actually that is MVP. @amadeu01 mentioned in https://github.com/tailec/ios-architecture/pull/2#issuecomment-459971301 , too.

    I have a doubt about https://github.com/tailec/ios-architecture/pull/2#issuecomment-460280849 .

    I think in MVP, presenter can have access to view (imports UIKit) but view models in MVVM are forbidden to do that.

    I think differences between MVP and MVVM are those have references of View directly or not.

    Presenter in MVP

    Presenter has a reference of View (or ViewController) that is abstracted as protocol in almost cases. To reflect state of Presenter, it calls method of abstructed View.

    protocol CounterView {
        func didChangeCount(_ presenter: CounterPresenter, count: Int)
    }
    
    class CounterViewController: UIViewController, CounterView {
        let presenter: CounterPresenter
        let countLabel: UILabel
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            presenter.view = self
        }
    
        func countUp() {
            presenter.countUp()
        }
    }
    
    extension CounterViewController: CounterView {
        func didChangeCount(_ presenter: CounterPresenter, count: Int) {
            countLabel?.text = "\(count)"
        }
    }
    
    class CounterPresenter {
        private(set) var count: Int = 0 {
            didSet {
                 view?.didChangeCount(self, count: count)
            }
        }
    
        weak var view: CounterView?
    
        func countUp() {
            count += 1
        }
    }
    

    ViewModel in MVVM

    ViewModel must not depend on View (or ViewController). Even if View is abstracted as Protocol, ViewModel must not depend on them. To reflect state of ViewModel, it notifies changes of state with closure (or RxSwift.Observable and so on). Closure is implemented outside of ViewModel, therefore ViewModel does not depend on View directly.

    class CounterViewController: UIViewController {
        let viewModel: CounterViewModel
        let countLabel: UILabel
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            viewModel.countChanged = { [weak countLabel] count in
                countLabel?.text = "\(count)"
            }
        }
    
        func countUp() {
            viewModel.countUp()
        }
    }
    
    class CounterViewModel {
        private(set) var count: Int = 0 {
            didSet {
                 countChanged?(count)
            }
        }
    
        var countChanged: ((Int) -> Void)?
    
        func countUp() {
            count += 1
        }
    }
    
    invalid 
    opened by marty-suzuki 7
Owner
Pawel Krawiec
iOS / React
Pawel Krawiec
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
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
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
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
Swift Interaction with VIPER Architecture

SwiftyVIPER SwiftyVIPER allows easy use of VIPER architecture throughout your iOS application. VIPER Architecture What is VIPER? Great question! VIPER

Cody Winton 121 Jan 2, 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
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
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
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
A holistic approach to iOS development, inspired by Redux and MVVM

Tempura is a holistic approach to iOS development, it borrows concepts from Redux (through Katana) and MVVM. ?? Installation Requirements CocoaPods Sw

Bending Spoons 693 Jan 4, 2023