NavigationRouter is a router implementation designed for complex modular apps, written in Swift.
Please note SwiftUI support requires iOS 13.0 or newer and macOS 10.15 or newer.
watchOS and tvOS support will eventually be added in future releases.
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.
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
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
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.
Check out DOCUMENTATION.md for details.
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.
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.