$30 off During Our Annual Pro Sale. View Details »

Migrating from UIKit to SwiftUI efficiently

yhkaplan
September 20, 2020

Migrating from UIKit to SwiftUI efficiently

yhkaplan

September 20, 2020
Tweet

More Decks by yhkaplan

Other Decks in Programming

Transcript

  1. Migrating from UIKit to Swi!UI efficiently
    final class MyViewController: UITableViewController {
    private var data = [String]()
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
    let d = data[indexPath.row]
    cell?.textLabel?.text = d
    return cell ?? UITableViewCell()
    }
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return data.count
    }
    }

    struct MyView: View {
    private var data = [String]()
    var body: some View {
    List(data, id: \.self) { d in
    Text(d)
    }
    }
    }
    1

    View Slide

  2. Self Intro
    — Name: Joshua Kaplan
    — Work: minne @ GMO Pepabo
    — Interests:
    !
    CI/CD,
    "
    frameworks, and more
    — Hobbies:
    #
    bread,
    $
    history, and running
    2

    View Slide

  3. Intro
    1. Why move to SwiftUI?
    2. Why not move to SwiftUI?
    3. Modernize Swift Usage
    4. Modernize UIKit usage
    5. Plan and prototype
    6. Two approaches
    7. Tips
    3

    View Slide

  4. Why move to Swi!UI
    — Do more with less code (for most things)
    — Easier to implement
    — The future of GUI development
    4

    View Slide

  5. Why not move to Swi!UI
    — Stability
    — iOS 12 and less compatibility
    — Low-level or high performance needs
    — Mixing can be difficult and painful without planning
    — How urgent?
    5

    View Slide

  6. Modernize Swi! usage
    — Migrate from Objective-C!
    — Use latest Swift version
    — Use Swiftier conventions
    — Use all the latest features
    — Get familiar with FRP frameworks
    6

    View Slide

  7. Modernize UIKit usage
    — Use auto layout
    — Support safe area
    — Components
    — Thin or no storyboards
    — Dynamic type and dark mode
    — Use declarative UIKit APIs
    7

    View Slide

  8. Plan and prototype
    8

    View Slide

  9. Prototype
    — Make a prototype
    — Identify screens/components not suited to SwiftUI
    — Change the design
    — Make an iOS 13-only feature
    9

    View Slide

  10. Architecture
    — Redux
    — The Composable Architecture (TCA)
    — MVVM
    10

    View Slide

  11. Two approaches
    11

    View Slide

  12. 12

    View Slide

  13. Tips
    — Don't mix too much
    — Start with easier screens
    — Don’t hurry
    — Study SwiftUI and Combine in advance
    13

    View Slide

  14. Conclusion
    14

    View Slide

  15. Thank you
    15

    View Slide

  16. Reference
    16

    View Slide

  17. Prototype
    — Shop.app
    17

    View Slide

  18. Combine
    18

    View Slide

  19. Docs
    — Official Documentation
    — RxSwift to Combine Cheatsheet
    — CombineϑϨʔϜϫʔΫ·ͱΊ
    19

    View Slide

  20. Code
    — CombineSwiftPlayground
    — Combine-MVVM
    — OpenCombine
    20

    View Slide

  21. Video
    — Introducing Combine
    — Combine in Practice
    21

    View Slide

  22. Books
    — Using Combine
    — Practical Combine
    — Understanding Combine
    — Combine: Asynchronous Programming with Swift
    22

    View Slide

  23. Swi!UI
    — Official Documentation
    23

    View Slide

  24. Books
    — Thinking in SwiftUI
    — SwiftUI by Tutorials
    24

    View Slide