Library / SDK
pointfreeco/swift-navigation avatar
pointfreeco/swift-navigation

swift-navigation: replacing three optionals with one enum so a SwiftUI or UIKit feature can show only one destination at a time

Bringing simple and powerful navigation tools to all Swift platforms, inspired by SwiftUI.

2,298 stars181 forksSwiftMIT

At a glance

What is it?
swift-navigation from pointfreeco is a Swift package with two core tools, observe and UIBinding, and two libraries on top of them, SwiftUINavigation and UIKitNavigation. Releases 2.11.0 to 2.11.2 landed between 2026-07-30 and 2026-08-31.
Who is it for?
Adopt swift-navigation if your SwiftUI or UIKit features already hold several optional models for sheets, alerts and drill-downs and you want one enum that makes invalid combinations unrepresentable. Skip it if your navigation is a single push or sheet, where plain SwiftUI modifiers are enough.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 16 days ago.
What is it written in?
Mainly Swift, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • pointfreeco/swift-navigation2,298 ★ · +6
Star history
Repository2026-10-142026-11-25
pointfreeco/swift-navigation2.3k2.3k

6 Stars in the last 42 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Two core tools, observe and UIBinding, sit under the SwiftUI and UIKit layers

The SwiftNavigation library is the foundation, and the repository describes more advanced libraries built on it: UIKitNavigation and SwiftUINavigation. Two primary tools come from the base. observe minimally observes changes in a model. UIBinding is a two-way binding that connects navigation and UI components to an observable model.

Two supplementary types round it out. UITransaction associates animations and other data with state changes. UINavigationPath is a type-erased stack of data that helps describe stack-based navigation.

The target list is wide. The library is meant for state management and navigation APIs on SwiftUI, UIKit and AppKit, and on non-Apple platforms such as Windows, Linux and Wasm. The package manifests hint at the toolchain range: Package.swift, plus [email protected], [email protected] and [email protected]. Those files let one repository serve several Swift versions.

The split matters when choosing what to import. The SwiftNavigation package is the dependency, but the README repeats in two callouts that the tools for SwiftUI come from the SwiftUINavigation library and the tools for UIKit from UIKitNavigation. Adding the package and importing only SwiftNavigation gives you observe and UIBinding, not the dot-chained bindings shown below.

Three optionals allow eight states but only four are valid

The README's motivating example is a feature that can present a sheet to add an item, drill down to edit an item and show an alert to confirm deletion. Modeled naively, that is three separate pieces of state:

swift
@Observable
class FeatureModel {
  var addItem: AddItemModel?
  var deleteItemAlertIsPresented: Bool
  var editItem: EditItemModel?
}

Three optionals give eight combinations: all nil, one non-nil, two non-nil or all three non-nil. Only four are valid, either all nil or exactly one non-nil. The other four can tell SwiftUI to present a sheet and an alert at the same time. That is not a valid thing to do, and SwiftUI prints a console message warning that it may crash the app in the future.

The view side uses the sheet, navigationDestination and alert modifiers with separate bindings. It works at first, and the README calls the extra complexity unnecessary.

The README's wording for the underlying problem is precise: by allowing the four invalid states, you can accidentally tell SwiftUI to present a sheet and an alert together. Nothing in the three-optional model stops that, because the type system sees three independent values. Every place that sets one of them must remember to clear the other two.

One optional enum makes at most one destination active, checked at compile time

The fix is an enum with a case per destination, held in a single optional:

swift
@Observable
class FeatureModel {
  var destination: Destination?

  enum Destination {
    case addItem(AddItemModel)
    case deleteItemAlert
    case editItem(EditItemModel)
  }
}

That gives compile-time verification that at most one destination is active. The remaining problem is that SwiftUI has no built-in way to drive navigation from such a model, and that is the gap the SwiftUINavigation tools fill.

The prerequisite is stated in a callout: depend on the SwiftNavigation package and import the SwiftUINavigation library. The enum also gets the @CasePathable macro, which lets you refer to cases with dot syntax just as you do with struct properties. In the README's diff, the annotation is added above enum Destination along with an import of SwiftNavigation.

With the enum in place, deep linking and testing become questions about one value. To land a user on the edit screen you set destination to the editItem case with an EditItemModel, and a test can assert on that single property. The README makes this argument in its UIKit section, where it says state-driven navigation unlocks deep linking and a more testable domain.

Dot-chaining a case turns the enum into the bindings SwiftUI already accepts

Once the enum is @CasePathable, a binding can be derived from one case of the destination property:

swift
import SwiftUINavigation
// ...
.sheet(item: $model.destination.addItem) { addItemModel in
  AddItemView(model: addItemModel)
}
.alert("Delete?", isPresented: Binding($model.destination.deleteItemAlert)) {
  Button("Yes", role: .destructive) { /* ... */ }
  Button("No", role: .cancel) {}
}
.navigationDestination(item: $model.destination.editItem) { editItemModel in
  EditItemView(model: editItemModel)
}

SwiftUI's own sheet, alert and navigationDestination modifiers stay in use. The alert case needs a special Binding initializer that turns a Binding of optional Void into a Binding of Bool, since deleteItemAlert carries no payload.

The result is one concise description of every place the feature can go. The cost is that the model and the view both depend on the enum shape, so adding a destination means changing the enum, the view and anything that switches over it.

UIKit navigation is fire-and-forget, which is what UIKitNavigation tries to change

UIKit has no state-driven navigation. Its tools are fire-and-forget: you call a method to trigger navigation, and nothing in your feature's state records it. The README's example is a button whose UIAction calls present with a SettingsViewController, animated.

That is easy to start with, but the README argues that driving navigation from state has real payoffs. More of the feature's logic lives in an isolated, testable domain. Deep linking comes for free, since you construct a piece of state describing the destination, hand it over and let the framework handle the rest.

UIKitNavigation brings navigation tools heavily inspired by SwiftUI to UIKit. It reuses the same FeatureModel with its @CasePathable Destination enum, and then drives a view controller from it. The import this time is UIKitNavigation, again alongside the SwiftNavigation package dependency. The view controller API itself is documented on the Swift Package Index page the badges link to.

The Makefile tests Apple simulators, while the Windows, Linux and Wasm claim has no test target in view

The overview claims support for Windows, Linux, Wasm and more. The Makefile in the repository tells a narrower story of what CI exercises. It defines test-ios, test-macos, test-tvos, test-watchos and test-examples, pinned to iOS 18.5, tvOS 18.5 and watchOS 11.5 simulators, with OTHER_SWIFT_FLAGS set to -DRESILIENT_LIBRARIES. Each platform runs the SwiftNavigation scheme tests and builds a DynamicFramework scheme.

No Windows, Linux or Wasm target appears in the visible part of the Makefile. That is not proof they are untested elsewhere, for example in the .github workflows, but a team targeting a non-Apple platform should look there first.

The Examples directory shows intended usage: CaseStudies, CaseStudiesTests, DynamicFramework, Inventory and an Examples.xcodeproj. Inventory and CaseStudies are the places to see the enum pattern in a larger app than the README snippets.

The DynamicFramework scheme appears in every platform block, built after the tests run. Its presence alongside -DRESILIENT_LIBRARIES suggests the package is also checked as a dynamically linked framework, though the README does not explain why. The Package.resolved file and a SwiftNavigation.xcworkspace sit at the root, so the workspace is the entry point for the simulator test commands.

Three releases in five weeks end with 2.11.2 on 2026-08-31, and the last push was 2026-09-04

The repository is not archived. Recent releases are 2.11.2 on 2026-08-31, 2.11.1 on 2026-08-28 and 2.11.0 on 2026-07-30. The last push was 2026-09-04. Two patch releases followed 2.11.0 within a month, so the 2.11 line was still being adjusted.

The license is MIT, and the homepage is pointfree.co. Documentation is hosted on the Swift Package Index, which the badges link to, and there is a Slack invite through pointfree.co.

One caution is about names. Searches for swift navigation return many unrelated results, and this repository is specifically the pointfreeco library for state-driven navigation, so check the repository name before following a tutorial.

Editorial conclusion

Adopt swift-navigation if your SwiftUI or UIKit features already hold several optional models for sheets, alerts and drill-downs and you want one enum that makes invalid combinations unrepresentable. Skip it if your navigation is a single push or sheet, where plain SwiftUI modifiers are enough. Before depending on it, import the right library for your UI framework, SwiftUINavigation or UIKitNavigation, because the SwiftNavigation package alone does not expose the tools the README describes.

Frequently asked questions

What does Swift Navigation do?

It gives SwiftUI, UIKit and AppKit a way to drive navigation from observable state, using observe and UIBinding, with SwiftUINavigation and UIKitNavigation built on top.

What is swift-navigation?

swift-navigation is a pointfreeco Swift package of navigation tools inspired by SwiftUI. It is MIT licensed, and its latest release is 2.11.2 from 2026-08-31.

Does swift-navigation work outside Apple platforms?

The overview says the tools support non-Apple platforms such as Windows, Linux and Wasm. The Makefile's visible test targets cover iOS, macOS, tvOS and watchOS only.

Official sources

  1. License: MIT
  2. pointfreeco/swift-navigation on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/pointfreeco-swift-navigation.svg)](https://hysenlabs.com/projects/pointfreeco-swift-navigation)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/pointfreeco-swift-navigation.svg)](https://hysenlabs.com/projects/pointfreeco-swift-navigation)

Was this useful?