Artisan is a MVVM framework for Swift using the bonding features from Pharos and constraints builder from Draftsman.


To run the example project, clone the repo, and run pod install from the Example directory first.


  • Swift 5.1 or higher
  • iOS 10.0 or higher



Artisan is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'Artisan ~> 3.0.9'
pod 'Draftsman ~> 1.0.9'
pod 'Pharos ~> 1.1.5'

Swift Package Manager from XCode

  • Add it using xcode menu File > Swift Package > Add Package Dependency
  • Add as Swift Package url
  • Set rules at version, with Up to Next Major option and put 3.0.9 as its version
  • Click next and wait

Swift Package Manager from Package.swift

Add as your target dependency in Package.swift

dependencies: [
    .package(url: "", .upToNextMajor(from: "3.0.9"))

Use it in your target as Artisan

    name: "MyModule",
    dependencies: ["Artisan"]


Read wiki for more detailed information.

Basic Usage

Creating MVVM Pattern using Artisan is easy. All you need to do is extend ViewMediator, TableCellMediator or CollectionCellMediator and implement bonding method.
For the example, If you want to create custom UITableViewCell:

import Artisan
import UIKit
import Draftsman
import Pharos

class MyCell: TableFragmentCell {
    lazy var title = builder(UILabel.self)
        .font(.boldSystemFont(ofSize: 16))
    lazy var subTitle = builder(UILabel.self)
        .font(.systemFont(ofSize: 12))
    // MARK: Dimensions
    var margin: UIEdgeInsets = .init(insets: 16)
    var spacing: CGFloat = 6
    override func planContent(_ plan: InsertablePlan) {
            .at(.fullTop, .equalTo(margin), to: .parent)
            .at(.bottomOf(title), .equalTo(spacing))
            .at(.fullBottom, .equalTo(margin), to: .parent)

class MyCellVM<Cell: MyCell>: TableCellMediator<Cell> {
    @Observable var model: MyModel
    init(model: MyModel) {
        self.model = model

    override func bonding(with view: Cell) {
        $ { $0.title }.relayValue(to: .relay(of: view.title, \.text))
        $ { $0.description }.relayValue(to: .relay(of: view.subTitle, \.text))

then add it to UITableView

import Artisan
import UIKit
import Draftsman
import Pharos

class MyViewController: UIViewController {
    var tableView: UITableView!
    var searchBar: UISearchBar!
    @Observable var searchPhrase: String?
    @Observable var models: [MyModel] = []

    override viewDidLoad() {
        $searchPhrase.bonding(with: .relay(of: searchBar, \.text)
            .multipleSetDelayed(by: 1)
            .whenDidSet(invoke: self, method: MyViewController.getData(from:))
        $models.compactMap { MyCellVM(model: $0) }
            .observe(on: .main)
            .relayValue(to: tableView.mediator.$cells)

    func getData(from: changes: Changes<String?>) {
        doGetDataFromAPI(for: { [weak self] data in
            self?.models = data

It will automatically run getData when user type in searchBar, with minimum interval between method call is 1 second and will update table cells with new data on Main Thread everytime you get data from API


Nayanda Haberty, [email protected]