Destinations

Destinations is a Swift library for UIKit and SwiftUI that provides an architectural framework for iOS apps, designed to truly decouple your UI from business logic, manage navigation flow, and remove boilerplate system presentation code. It is based on a philosophy that emphasizes clear separation of concerns, that each significant View or UIViewController in an app should not know about each other, and that UI and functionality should be able to be easily substituted as your needs change. Destinations enables your user interfaces to focus again on the user. It handles app routing, the plumbing between logic and UI, and significantly reduces boilerplate code in your apps.
- Enables clean separation of concerns between your interfaces, datasources, and other application logic
- Allows you to easily replace business logic, datasources, and UI for A/B testing or reusing Views in different contexts
- Reduces development time – provides built-in implementations for many system presentation types, reduces code churn as feature flows change
- Provides easy deep linking capability
- Provides the ability to display and test sections of your apps in isolation
- A flexible and extensible, protocol-based system to fit your project's needs, including custom UI
- A similar API for both UIKit and SwiftUI, and generic enough to allow further platform support. Supports pure UIKit and SwiftUI apps, but also supports hybrid apps with SwiftUI content hosted within UIKit controllers.
Getting Started
Get started with the user guide for detailed explanations and examples.
Please be sure to check out the Examples projects to see some simple implementations of Destinations in UIKit and SwiftUI apps, or dive deep into the source Documentation.
Overview
Keeping application logic, tight couplings to datasources and system APIs, and knowledge of other views out of your user interfaces can be a constant battle, compounded by often tight timelines to get a feature shipped. Destinations is a library designed from the ground up to address this problem.
In Destinations, user interfaces have no knowledge of the actions they should take. They have no knowledge of datasources, business logic, or other UI screens, either. These things – View presentations, API requests, logic – are handled by state models you create which and interface with the View's Destination. Actions that can be taken in a particular Destination are represented by an enum of events you define. Thus, when a user interacts with a UI element the only thing the View sends along to the state model is the event's enum value. In this way, app functionality is no longer tightly coupled to UI and can be switched or modified easily. A button in View A can display View B, even though A has no knowledge of B, or even that it should present a View! A button could make a server request or show a modal sheet simply by switching its associated action, with no direct knowledge of either.
But more than that, abstracting navigation and View presentation actions, along with datasource request handling, enables Destinations to act as a framework for your app's feature flows. In fact Destinations handles most UIKit and SwiftUI presentation tasks for you, allowing you to focus on your app's functionality instead of writing boilerplate code.
There's a few main conceptual types in Destinations:
Flow: Manages the creation, appearance, and removal of Destinations as a user navigates through the app.
Destination: Represents a distinct view in the app, and coordinates routing and requests. Generally not directly used.
State Model: Custom objects specific to each Destination which handle view state, business logic, and responds to events sent by the view.
Provider: Builds and configures a Destination, its view, and the state model. Used by Flow object to present new views.
Event: Typically represents a user interface interaction, generally used to perform a Destination presentation or an Interactor request. Events are the foundation for decoupling the UI from the actions that the user interactions should trigger.
Interactor: Represents an object that performs some work, typically by interfacing with an API, doing background processing, or some other self-contained work.
Action: A higher-level representation of an Interactor request. These can be used to build complex sequences of actions.
Presenting a Destination