Swiftpack.co - corteggo/NavigationRouter as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by corteggo.
corteggo/NavigationRouter 1.0.3
A router implementation designed for complex modular apps, written in Swift
⭐️ 70
🕓 1 week ago
iOS macOS
.package(url: "https://github.com/corteggo/NavigationRouter.git", from: "1.0.3")


NavigationRouter is a router implementation designed for complex modular apps, written in Swift.

Features :star2:

  • ☑ Decoupled routing registration.
  • Decoupled navigation between views and modules.
  • ☑ Custom navigations with parameters.
  • Navigation interceptions to make things easier (onboardings, tutorials...).
  • ☑ Lightweight codebase.
  • ☑ Works with iOS, iPadOS and macOS Catalyst.
  • ☑ Works with both UIKit and SwiftUI.
  • ☑ Supports external navigation handling.
  • ☑ Supports multiple UIScene instances.
  • ☑ Supports any kind of authentication for routing permissions. Including OAuth authentication callbacks.

Please note SwiftUI support requires iOS 13.0 or newer and macOS 10.15 or newer.

Supported platforms :iphone:

  • iOS 11.0+.
  • macOS 10.15+.
  • Xcode 11.0+.
  • Swift 5.0+.

watchOS and tvOS support will eventually be added in future releases.

How does it work :question:

Writing simple apps is easy but writing large ones can be very complex. At that point modular architectures usually come to the rescue, but it's hard to navigate between views and modules without coupling them, ending in a very complex dependency graph that's hard to maintain and developers leave your company because the project becomes no longer attractive.

This library tries to fix that problem, so your developers are still happy after many years of app development. It has been designed to navigate between different views and modules without actually knowing the destination object, making things easier.

I recommend you to read my article about Building complex modular architectures with SwiftUI, Combine and Swift Package Manager (SPM) to understand how this router works internally.

Installation :gear:

Swift Package Manager

Swift Package Manager is a tool for automating the distribution of Swift code and it is integrated in Xcode. Once you have your project ready, adding NavigationRouter as a dependency is as easy as adding it to the dependencies value of your Package.swift manifest file or to the "Swift packages" tab in Xcode.

dependencies: [
    .package(url: "https://github.com/corteggo/NavigationRouter.git", .branch("main"))

You can choose between always using the latest version (main branch) or using a specific version.


CocoaPods is a centralized dependency manager for iOS projects. For usage and installation instructions, please visit their website. To integrate NavigationRouter into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'NavigationRouter', :git => 'https://github.com/corteggo/NavigationRouter.git', :branch => 'main'

I've decided not to make this project available in central repository. Please consider dropping CocoaPods usage as it will no longer be supported by this library in the future, given that Swift Package Manager now supports binaries and resources as of Xcode 12. There's no need to use CocoaPods anymore.

How to use it :grey_question:

Check out DOCUMENTATION.md for details.

Sample project

Please download the project and run "NavigationRouterTestApp" for a working example. It supports iOS, iPadOS and macOS Catalyst and shows all available scenarios described here.

Known issues :bangbang:

Navigating between SwiftUI views

Please note when using two SwiftUI views hosted with UIHostingController a weird animation happens when you're navigating between views using different UINavigationBar display modes. As a workaround, when using SwiftUI for your app, always choose between "large" or "inline" display modes but do not mix them in the same navigation route. You can also leave it at .automatic to avoid this problem. This has already been reported to Apple via Feedback Assistant as FB7648851.

Miscelanea :busstop:

  • Changelog: check out CHANGELOG.md for details.
  • Credits: NavigationRouter is owned and maintained by corteggo.
  • License: NavigationRouter is released under the MIT license. See LICENSE for details.
  • Want to contribute? Suggest your idea as a feature request for this project or create a bug report.


Stars: 70
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

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