Swiftpack.co - cerihughes/provident as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by cerihughes.
cerihughes/provident 7.0.0
A View Controller Provider framework for Swift
⭐️ 0
🕓 5 days ago
iOS macOS tvOS
.package(url: "https://github.com/cerihughes/provident.git", from: "7.0.0")

Build Status codecov.io


Provident is a view controller provider framework that uses inversion of control to simplify view controller creation.

  • Code that needs to create a view controller doesn't need to know how to create a view controller or what its dependencies are
  • The view controller's internals (whether it uses storyboards, "vanilla" UIKit, SwiftUI etc) are hidden away, allowing a more declarative programming style
  • Allows apps to avoid a common iOS coding trap where view controllers that present other view controllers (ad infinitum) need to know about all of the dependencies of those child view controllers
  • Makes it a lot easier to introduce an architecture where dependencies and other services are loosely coupled from the rest of the system

Common Pitfalls with View Controller Creation Code

1) Different view controller "flavours" require flavour-specific initialisation code

  • if using UIKit, the calling code needs to instantiate the view controller directly
  • if using Storyboards, the calling code needs to use UIStoryboard to create the view controller
  • if using SwiftUI, the calling code needs to wrap the View in a UIHostingController

If a view controller is reimplemented as a different "flavour" (e.g. refactored from a Storyboard to SwiftUI), all calling code must be changed accordingly. Essentially, some of the internals of the view controller are exposed, reducing encapsualtion.

Provident uses the concept of a ViewControllerProvider to solve this, moving all of the logic for view controller creation to a single place.

2) V


Stars: 0
Last commit: 5 days ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

5 days ago

Changes in Registry:

func createViewController(from token: T, context: C) -> ViewController?


func createViewController(token: T, context: C) throws -> ViewController

Adds a backward compat-like Registryextension with:

func findViewController(token: T, context: C) -> ViewController?

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics