Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

A router implementation designed for complex modular apps, written in Swift

License

Notifications You must be signed in to change notification settings

SimpleNexus/NavigationRouter

 
 

Repository files navigation

NavigationRouter

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

Features 🌟

  • 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 📱

  • 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 ❓

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 ⚙️

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

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 ❔

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 ‼️

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 🚏

  • 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.

About

A router implementation designed for complex modular apps, written in Swift

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 99.6%
  • Ruby 0.4%