Swiftpack.co -  wwt/SwiftCurrent as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
wwt/SwiftCurrent
A library for managing complex workflows in Swift
.package(url: "https://github.com/wwt/SwiftCurrent.git", from: "4.5.3")

SwiftCurrent

Supported Platforms Swift Package Manager Pod Version License Build Status Code Coverage

Welcome

SwiftCurrent is a library that lets you easily manage journeys through your Swift application.

It comes with built-in support for UIKit and SwiftUI app-routing. In SwiftCurrent workflows are a sequence of operations. Those operations usually show views in an application. The workflow describes the sequence of views and manages what view should come next. Your views are responsible for performing necessary tasks before proceeding forward in the workflow, like processing user input.

https://user-images.githubusercontent.com/33705774/132767762-7447753c-feba-4ef4-b54c-38bfe9d1ee82.mp4

Why should I use SwiftCurrent?

Architectural patterns and libraries that attempt to create a separation between views and workflows already exist. However, SwiftCurrent is different. We took a new design approach that focuses on

  • A Developer Friendly API: The library was built with developers in mind. It started with a group of developers talking about the code experience they desired. Then the library team took on whatever complexities were necessary to bring them that experience.
  • Compile-time safety: We tell you at compile time everything we can so you know things will work.
  • Minimal Boilerplate: We have hidden this as much as possible. We hate it as much as you do and are constantly working on cutting the cruft.

From there, we created a library that:

  • Isolates your views: You can design your views so that they are unaware of the view that will come next.
  • Easily reorders views: Changing view order is as easy as ⌘+⌥+[ (moving the line up or down)
  • Composes workflows together: Create branching flows easily by joining workflows together.
  • Creates conditional flows: Make your flows robust and handle ever-changing designs. Need a screen only to show up sometimes? Need a flow for person A and another for person B? We've got you covered.

Quick Start

Why show a quick start when we have an example app? Because it's so easy to get started, we can drop in 2 code snippets, and you're ready to go! This quickstart uses Swift Package Manager and SwiftUI, but for other approaches, see our installation instructions.

.package(url: "https://github.com/wwt/SwiftCurrent.git", .upToNextMajor(from: "4.5.0")),
...
.product(name: "SwiftCurrent", package: "SwiftCurrent"),
.product(name: "SwiftCurrent_SwiftUI", package: "SwiftCurrent")

Then make your first FlowRepresentable view:

import SwiftCurrent
import SwiftUI
struct OptionalView: View, FlowRepresentable {
    weak var _workflowPointer: AnyFlowRepresentable?
    let input: String
    init(with args: String) { input = args }
    var body: some View { Text("Only shows up if no input") }
    func shouldLoad() -> Bool { input.isEmpty }
}
struct ExampleView: View, PassthroughFlowRepresentable {
    weak var _workflowPointer: AnyFlowRepresentable?
    var body: some View { Text("This is ExampleView!") }
}

Then from your ContentView or whatever view (or app) you'd like to contain the workflow, add the following view to the body:

import SwiftCurrent_SwiftUI
// ...
var body: some View { 
    // ... other view code (if any)
    WorkflowLauncher(isLaunched: .constant(true), startingArgs: "Skip optional screen") {
        thenProceed(with: OptionalView.self) {
            thenProceed(with: ExampleView.self)
        }
    }
}

And just like that, you've got a workflow! You can now add more items to it or re-order the items that are there. To understand more of how this works and what is there check out our developer docs.

Check out our example apps

We have example apps for both SwiftUI and UIKit that show SwiftCurrent in action. They're even tested so you can see what it's like to test SwiftCurrent code. To run it locally, start by cloning the repo, open SwiftCurrent.xcworkspace and then run the SwiftUIExample scheme or the UIKitExample scheme.

See this to learn more

For specific documentation check out:

Feedback

If you like what you've seen, consider giving us a star! If you don't, let us know how we can improve.

Stars Twitter

Special Thanks

SwiftCurrent would not be nearly as amazing without all of the great work done by the authors of our test dependencies:

GitHub

link
Stars: 90
Last commit: Yesterday

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

Release 4.5.3
2 days ago

📝 Documentation

  • #131 - Proofread and Made Minimal Changes to Creating Workflows in SwiftUI
  • #132 - Proofread and Made Minor Changes to Creating Workflows in UIKit
  • #130 - Proofread and made minimal changes to Controlling Presentation.
  • #137 - Proofread and Made Updates to Installation
  • #135 - Proofread and Made a Couple of Changes to Type Erasure
  • #141 - Update Working with Modals.md
  • #142 - Proofread and Updated Working with NavigationView
  • #139 - Updated Using Storyboards Guide
  • #140 - Updated Why This Library Section
  • #138 - Made changes to Using Programmatic Views Guide.
  • #136 - Made Changes to Getting Started with SwiftUI
  • #133 - Made Changes to Creating Workflows Section

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