Swift 实现的路由解耦框架

Overview

UIRouter: Router in Swift CocoaPods Compatible Cocoapods Bitbucket open issues Documentation

UIRouter 是一个用Swift实现的路由解耦框架. API文档

安装

CocoaPods

pod 'UIRouter', '~> 0.2.0.alpha'

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/wxlpp/UIRouter", .upToNextMajor(from: "0.2.0"))
]

使用

页面注册

import UIKit
import UIRouter

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // 可以在此调用 autoRegisterIfNeed 进行页面预注册,否则会在第一次页面路由发生时进行注册
        application.router.autoRegisterIfNeed()
        // 注册拦截器,WebInterceptor 是一个默认实现的 htttp 协议拦截器
        application.router.register(interceptors: [WebInterceptor()])
        // 注册错误处理器进行错误处理
        application.router.registerErrorHandler(RouteErrorHandler())
        return true
    }
}
import UIKit
import UIRouter

public final class UserProfileViewController: UIViewController {}

// MARK: 路由

extension UserProfileViewController: Routable {
    public static var paths: [String] {
        ["user/profile/:id"]
    }

    public static func route(parameters: RouterParameters, object: Any?, completion: @escaping RouteCompletionHandler<UserProfileViewController>) {
        if let userID: String = parameters.get("userID") {
            completion(.success(UserProfileViewController()))
        } else {
            completion(.failure(RouteError.parameterValidationFailed(vcType: Self.self, name: "userID")))
        }
    }
}

页面路由

UIApplication.shared.route(url: "user/profile/123456?name=wxlpp").push()
UIApplication.shared.route(url: "https://github.com/wxlpp/UIRouter").present()
UIApplication.shared.route(url: "flutter://shop.com/home").presentWithNavigationController(UINavigationController.self)

错误拦截

import UIRouter

class RouteErrorHandler: RouteErrorHandling {
    func handleRouteError(_ error: RouteError) {
        #if DEBUG
            let vc = ErrorDetailsViewController(error: error)
            UIApplication.shared.route(viewcontroller: vc).presentWithNavigationController(UINavigationController.self)
        #else
            debugPrint(error.errorDescription)
        #endif
    }

    func handleCustomError(_ error: Error) {
        //这里对业务错误信息进行处理,比如用户鉴权失败弹出登录页面
    }
}
Issues
Releases(0.2.0.alpha)
  • 0.2.0.alpha(May 3, 2021)

Owner
Wang Xiaolong
while(sleep){money++;}
Wang Xiaolong
LiteRoute is easy transition for your app. Written on Swift 4

LiteRoute Description LiteRoute is easy transition between VIPER modules, who implemented on pure Swift. We can transition between your modules very e

Vladislav Prusakov 90 Nov 10, 2021
📱📲 Navigate between view controllers with ease. 💫 🔜 More stable version (written in Swift 5) coming soon.

CoreNavigation ?? ?? Navigate between view controllers with ease. ?? ?? More stable version (written in Swift 5) coming soon. Getting Started API Refe

Aron Balog 69 Nov 6, 2021
Declarative URL- and state-based router written in Swift.

MonarchRouter Powerful functional state-based router written in Swift. Monarch Router is a declarative routing handler that is capable of managing com

Eliah Snakin 33 Sep 9, 2021
📱 Launch external apps, and deeplink, with ease using Swift!

Appz ?? Deeplinking to external applications made easy Highlights Web Fallback Support: In case the app can't open the external application, it will f

Kitz 1.1k Nov 23, 2021
A URL Router for iOS, written in Swift

SwiftRouter A URL Router for iOS, written in Swift, inspired by HHRouter and JLRoutes. Installation SwiftRouter Version Swift Version Note Before 1.0.

Chester Liu 265 Nov 8, 2021
⛵️ Elegant URL Routing for Swift

URLNavigator ⛵️ URLNavigator provides an elegant way to navigate through view controllers by URLs. URL patterns can be mapped by using URLNavigator.re

Suyeol Jeon 2.8k Nov 26, 2021
Swift tool to generate Module Interfaces for Swift projects.

ModuleInterface Swift tool to generate Module Interfaces for Swift projects. What is a Module Interface A Module Interface is what we commonly get usi

Jorge 67 Nov 2, 2021
Native MongoDB driver for Swift, written in Swift

Installation | Tutorial | Basic usage | About BSON | Codable | Community | How to help A fast, pure swift MongoDB driver based on Swift NIO built for

null 625 Nov 18, 2021
ObjectBox Swift - persisting your Swift objects superfast and simple

ObjectBox Swift ObjectBox is a superfast, light-weight object persistence framework. This Swift API seamlessly persists objects on-device for iOS and

ObjectBox 337 Nov 12, 2021
Swift Modules, a swift module (or package) manager #fuck_xcode #terminal_rocks

Swift Modules The Swift Modules manager similar to the JavaScript world's npm and bower Installation $ curl "https://raw.github.com/jankuca/swm/master

Jan Kuča 60 Jun 3, 2021
MisterFusion is Swift DSL for AutoLayout. It is the extremely clear, but concise syntax, in addition, can be used in both Swift and Objective-C. Support Safe Area and Size Class.

MisterFusion MisterFusion makes more easier to use AutoLayout in Swift & Objective-C code. Features Simple And Concise Syntax Use in Swift and Objecti

Taiki Suzuki 318 Nov 7, 2021
try! Swift Tokyo Screenshot 1 Screenshot 2 2019 swift timepiece realm kingfisher acknowlist ☆248

trySwiftApp try! Swift Conference App try! Swift Presentations You can find an overview of speakers and their presentations, including slides and vide

try! Swift 249 Jun 24, 2021
Calculate your Equated Monthly instalment (EMI) for Home loan, Housing loan, Car loan & Personal loan (Based on Uncle Bob's clean architecture approach and special thanks to http://clean-swift.com/clean-swift-ios-architecture)

![Language](https://img.shields.io/badge/language-Swift 3.0-orange.svg) Calculate your Equated Monthly instalment (EMI) for Home loan, Housing loan, C

Tirupati Balan 16 Aug 16, 2020
Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and more…)

Perfect: Server-Side Swift 简体中文 Perfect: Server-Side Swift Perfect is a complete and powerful toolbox, framework, and application server for Linux, iO

PerfectlySoft Inc. 13.9k Nov 23, 2021
Swift Express is a simple, yet unopinionated web application server written in Swift

Documentation <h5 align="right"><a href="http://demo.swiftexpress.io/">Live ?? server running Demo <img src="https://cdn0.iconfinder.com/data/icons/

Crossroad Labs 854 Oct 7, 2021
Swift backend / server framework (Pure Swift, Supports Linux)

NetworkObjects NetworkObjects is a #PureSwift backend. This framework compiles for OS X, iOS and Linux and serves as the foundation for building power

Alsey Coleman Miller 265 Nov 18, 2021
Swift library to manage in app notification in swift language, like WhatsApp, Telegram, Frind, ecc.

InAppNotify - Manage in App notifications During develop of my app Frind, I needed to manage in app notifications like whatsapp or telegram, but i did

Luca Becchetti 436 Sep 30, 2021
The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable

Q: How will my calendar dateCells look with this library? A: However you want them to look. More Images Features Range selection - select dates in a r

PatchTheCode 7.1k Nov 21, 2021
Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux)

SwiftFoundation Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. Goals Provide a cross-platform in

null 621 Nov 17, 2021
:octocat: AdaptiveController is a 'Progressive Reduction' Swift UI module for adding custom states to Native or Custom iOS UI elements. Swift UI component by @Ramotion

ADAPTIVE TAB BAR 'Progressive Reduction' module for adding custom states to Native or Custom UI elements. We specialize in the designing and coding of

Ramotion 2k Nov 9, 2021
Swift Modules, a swift module (or package) manager #fuck_xcode #terminal_rocks

Swift Modules The Swift Modules manager similar to the JavaScript world's npm and bower Installation $ curl "https://raw.github.com/jankuca/swm/master

Jan Kuča 60 Jun 3, 2021
The Swift Package Index is the place to find Swift packages!

The Swift Package Index Find the best Swift libraries and frameworks that support the Swift Package Manager. Reconciliation, Ingestion, and Analysis T

Swift Package Index 290 Nov 18, 2021
Swift Collections is an open-source package of data structure implementations for the Swift programming language.

Swift Collections is an open-source package of data structure implementations for the Swift programming language.

Apple 1.9k Nov 26, 2021
Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.

BlueSocket Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux. Prerequisites Swift Swift Open Source swift-4.0

Kitura 1.3k Nov 20, 2021
Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and more…)

Perfect: Server-Side Swift 简体中文 Perfect: Server-Side Swift Perfect is a complete and powerful toolbox, framework, and application server for Linux, iO

PerfectlySoft Inc. 13.9k Nov 19, 2021
RSA public/private key encryption, private key signing and public key verification in Swift using the Swift Package Manager. Works on iOS, macOS, and Linux (work in progress).

BlueRSA Swift cross-platform RSA wrapper library for RSA encryption and signing. Works on supported Apple platforms (using Security framework). Linux

Kitura 109 Oct 27, 2021
Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and more…)

Perfect: Server-Side Swift 简体中文 Perfect: Server-Side Swift Perfect is a complete and powerful toolbox, framework, and application server for Linux, iO

PerfectlySoft Inc. 13.9k Nov 23, 2021
The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable

Q: How will my calendar dateCells look with this library? A: However you want them to look. More Images Features Range selection - select dates in a r

PatchTheCode 7.1k Nov 20, 2021
AdaptiveController is a 'Progressive Reduction' Swift UI module for adding custom states to Native or Custom iOS UI elements. Swift UI component by @Ramotion

ADAPTIVE TAB BAR 'Progressive Reduction' module for adding custom states to Native or Custom UI elements. We specialize in the designing and coding of

Ramotion 2k Nov 9, 2021