All Projects → pixeldock → RxSwift-Xcode-Templates

pixeldock / RxSwift-Xcode-Templates

Licence: other
A handful of Xcode file templates for projects that use RXSwift and MVVM

Projects that are alternatives of or similar to RxSwift-Xcode-Templates

MVVM-Templates
Templates for MVVM architecture for swift (based on RxSwift)
Stars: ✭ 14 (-81.82%)
Mutual labels:  rxswift, xcode-templates
iOS Started Kit
iOS Started Kit: Clean Architecture + RxSwift + Moya
Stars: ✭ 12 (-84.42%)
Mutual labels:  rxswift
Zhuishushenqi
追书神器Swift版客户端(非官方)。 不断更新中......
Stars: ✭ 196 (+154.55%)
Mutual labels:  rxswift
Passcode
🔑 Passcode for iOS Rxswift, ReactorKit and IGListKit example
Stars: ✭ 254 (+229.87%)
Mutual labels:  rxswift
Recaptcha
[In]visible ReCaptcha v2 for iOS
Stars: ✭ 208 (+170.13%)
Mutual labels:  rxswift
RxSwift-VIPER-iOS
RxSwiftVIPER is an sample iOS App written in RxSwift using the VIPER architecture. Also RxSwiftVIPER is not a strict VIPER architecture.
Stars: ✭ 47 (-38.96%)
Mutual labels:  rxswift
Moya
Network abstraction layer written in Swift.
Stars: ✭ 13,607 (+17571.43%)
Mutual labels:  rxswift
mvvm-ios
A sample app to demonstrate MVVM implementation in iOS
Stars: ✭ 26 (-66.23%)
Mutual labels:  rxswift
RxScreenProtectKit
Protect the screen from recording 🔐
Stars: ✭ 17 (-77.92%)
Mutual labels:  rxswift
Gitiny
An iOS app for GitHub with exploring trending
Stars: ✭ 247 (+220.78%)
Mutual labels:  rxswift
Rxdatasources
UITableView and UICollectionView Data Sources for RxSwift (sections, animated updates, editing ...)
Stars: ✭ 2,784 (+3515.58%)
Mutual labels:  rxswift
Lockwise Ios
Firefox's Lockwise app for iOS
Stars: ✭ 224 (+190.91%)
Mutual labels:  rxswift
Cyanic
Declarative, state-driven UI framework
Stars: ✭ 32 (-58.44%)
Mutual labels:  rxswift
V2ex
An iOS client written in Swift for V2EX
Stars: ✭ 208 (+170.13%)
Mutual labels:  rxswift
Swift-Viper-Weather-App
iOS app with Clean Architecture
Stars: ✭ 20 (-74.03%)
Mutual labels:  rxswift
Rxkingfisher
Reactive extension for the Kingfisher image downloading and caching library
Stars: ✭ 190 (+146.75%)
Mutual labels:  rxswift
Rxswift Tutorial
RxSwift 学习资料(学习教程、开源项目)
Stars: ✭ 236 (+206.49%)
Mutual labels:  rxswift
BringMyOwnBeer-
PunkAPI(BrewDog) 을 이용한 RxSwift-MVVM 예제 (Naver Tech Concert)
Stars: ✭ 80 (+3.9%)
Mutual labels:  rxswift
KDInstagram
Instagram Clone built in Swift. Utilize three design patterns in three major modules.
Stars: ✭ 119 (+54.55%)
Mutual labels:  rxswift
RxSwift-MVVM-iOS
SwiftMVVM is an sample iOS App written in Swift using the MVVM architecture.
Stars: ✭ 96 (+24.68%)
Mutual labels:  rxswift

RxSwift Xcode file templates

GitHub release License Xcode version Platform Swift Twitter Blog

A handful of Xcode file templates for projects that use RxSwift and my own variation of MVVM

What this is about:

These file templates are meant to be used for the following app architecture setup:

Let's call each "screen" or "view" in the app a Scene. So if you have an app that has a list view, a detail view and a login view you have 3 Scenes.

Each Scene consists of the following elements:

ViewController

Does

  • initialize and layout its subviews
  • handle user input (if data needs to be fetched or stored it relays that to the ViewModel)
  • show Displayable Items that are provided by the ViewModel

Does Not

  • have any access to API, DataStore, UserDefaults
  • push other ViewControllers or pop itself
  • present other ViewControllers modally
  • show Alerts
  • format Data to be displayable in Views (e.g. AttributedStrings, DateFormatters)

ViewModel

Does

  • fetch data from API
  • fetch / store / update Data from DataStore
  • fetch / store / update Data from UserDefaults
  • format Data to be displayable by the ViewController (e.g. Attributed Strings, DateFormatters)

Does Not

  • have any access to UIElements (does not even import UIKit!)

Router

Does

  • push other Scenes (if they are should be on the same navigaton stack)
  • generate a RouteRequest for Scenes that should be presented by the main AppRouter

Does Not

  • have any access to UIElements (does not even import UIKit!)
  • have any access to API, DataStore, UserDefaults

Builder

Does

  • initialize ViewController, ViewModel and Router
  • provide the ViewController to the outside world (via the viewController() method)
  • if the Scene needs some initial data it is injected into the Builder who then injects it into the ViewModel

Does Not

  • do anything else ;-)

image

Initializing a new scene

When you want to show a new scene you never initialize any of its components yourself. Always ask the Scene's Builder to provide the Scene's ViewController via its static viewController() method:

let nextViewController = NextBuilder.viewController()

If the new Scene needs some initial data you inject it into the new Scene's Builder.

A simple example:
You have a CarListScene that shows a list of cars. When the user taps on a car in the list you want to navigate to a CarDetailsScene that shows the details of the selected car. To hand the carID to the Details Scene you inject it into the CarDetailsBuilder:

class CarListRouter {
    weak var viewController: CarListViewController?

    func navigateToDetails(withCarID carID: String) {
        let detailsViewController = CarDetailsBuilder.viewController(withCarID: carID)
        viewController?.navigationController?.pushViewController(detailsViewController, animated: true)
    }
}

The CarDetailsBuilder then injects the data into the CarDetailsViewModel:

struct CarDetailsBuilder {

    static func viewController(withCarID carID: String) -> UIViewController {
        let viewModel = CarDetailsViewModel(withCarID: carID)
        let router = CarDetailsRouter()
        let viewController = CarDetailsViewController(withViewModel: viewModel, router: router)
        router.viewController = viewController

        return viewController
    }
}

And then the CarDetailsViewModel prepares displayable data for the CarDetailsViewController as it always does.

How to use the Xcode templates:

  1. Download the RxSwift folder and add it to the following folder on your machine: ~/Library/Developer/Xcode/Templates (You might need to create that folder if does not exist yet)

  2. When you want to add a new scene to your app, open the New File dialog and choose RxSwift in the left column

  3. Select Scene and click Next

  4. Enter a name for the Scene. As you can see that name will be used as a prefix for all the 4 classes that will be needed for the scene (see above)

  5. Click Next and save the scene. Xcode now creates the 4 classes needed for the scene.

Requirements

  • Xcode 9 (for prior versions use 0.4.0)
  • Swift 4
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].