SwiftRouter alternatives and similar libraries
Based on the "Utility" category.
Alternatively, view SwiftRouter alternatives based on common mentions on social networks and blogs.
-
swift-algorithm-club
Algorithms and data structures in Swift, with explanations! -
SwifterSwift
A handy collection of more than 500 native Swift extensions to boost your productivity. -
BlocksKit
The Objective-C block utilities you always wish you had. -
libextobjc
A Cocoa library to extend the Objective-C programming language. -
InAppSettingsKit
This iOS framework allows settings to be in-app in addition to or instead of being in the Settings app. -
DifferenceKit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection. -
EKAlgorithms
EKAlgorithms contains some well known CS algorithms & data structures. -
EZSwiftExtensions
:smirk: How Swift standard types and classes were supposed to work. -
Reusable
A Swift mixin for reusing views easily and in a type-safe way (UITableViewCells, UICollectionViewCells, custom UIViews, ViewControllers, Storyboards…) -
ObjectiveSugar
ObjectiveC additions for humans. Ruby style. -
SwiftLinkPreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images. -
WhatsNew
Showcase new features after an app update similar to Pages, Numbers and Keynote. -
BFKit-Swift
BFKit-Swift is a collection of useful classes, structs and extensions to develop Apps faster. -
BFKit
BFKit is a collection of useful classes and categories to develop Apps faster. -
RateLimit
Simple utility for only executing code every so often. -
VTAcknowledgementsViewController
Acknowledgements screen displaying a list of licenses, for example from CocoaPods dependencies. -
ReadabilityKit
Preview extractor for news, articles and full-texts in Swift -
ObjectiveKit
Swift-friendly API for a set of powerful Objective C runtime functions. -
SwiftFoundation
Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux) -
AssistantKit
Easy way to detect iOS device properties, OS versions and work with screen sizes. Powered by Swift. -
DeviceGuru
DeviceGuru is a simple lib (Swift) to know the exact type of the device, e.g. iPhone 6 or iPhone 6s. Please ⭐️ this repo on the top right corner to make this repo popular. -
SwiftyUtils
All the reusable code that we need in each project -
Retry
Haven't you wished for `try` to sometimes try a little harder? Meet `retry` -
Standard Template Protocols
Protocols for your every day iOS needs -
YAML.framework
Proper YAML support for Objective-C. Based on recommended libyaml. -
SBConstants
Generate a constants file by grabbing identifiers from storyboards in a project. -
ReflectableEnum
Reflection for enumerations in Objective-C. -
ZamzamKit
A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks. -
Datez
📆 Breeze through Date, DateComponents, and TimeInterval with Swift! -
XestiMonitors
An extensible monitoring framework written in Swift
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SwiftRouter or a related project?
README
SwiftRouter
A URL Router for iOS, written in Swift, inspired by HHRouter and JLRoutes.
Installation
SwiftRouter Version | Swift Version | Note |
---|---|---|
Before 1.0.7 | 2.0 | n/a |
1.0.7 | 2.2 | n/a |
2.0.0 | 3.0 | n/a |
2.1.0 | 3.0 | Breaking changes by adopting exception |
3.0.0 | 4.0 | @objc should be used with properties |
Carthage
SwiftRouter is compatible with Carthage. Add it to your Cartfile
:
github "skyline75489/SwiftRouter"
CocoaPods
pod 'JLSwiftRouter'
use_frameworks!
Manually
Add SwiftRouter.swift
in your project.
Usage
Routing ViewController
Define properties in your custom ViewController:
class UserViewController: UIViewController {
@objc var userId:String?
@objc var username:String?
@objc var password:String?
}
Map URL to ViewController:
import SwiftRouter
let router = Router.shared
router.map("/user/:userId", controllerClass: UserViewController.self)
Get instance of ViewController directly from the URL. Parameters will be parsed automatically:
let vc = router.matchController("/user/1?username=hello&password=123")!
XCTAssertEqual(vc.userId, "1")
XCTAssertEqual(vc.username, "hello")
XCTAssertEqual(vc.password, "123")
This will load controller using init() method. If you want to load view controller from storyboard - use:
let vc = router.matchControllerFromStoryboard("/user/1?username=hello&password=123",
storyboardName: "MyStoryboard")!
This code will load controller from storyboard named MyStoryboard.storyboard. Just don't forget to set that controller identifier in storyboard to its class name. In this case UserViewController
.
Push custom ViewController:
router.routeURL("/user/123", navigationController: self.navigationController!)
// The custom ViewController will be pushed with parameters.
Routing handler
Define your custom handler function and map it to URL:
router.map("/user/add", handler: { (params:[String: String]?) -> (Bool) in
XCTAssertNotNil(params)
if let params = params {
XCTAssertEqual(params["username"], "hello")
XCTAssertEqual(params["password"], "123")
}
return true
})
Call the handler from router:
router.routeURL("/user/add?username=hello&password=123")
// The handler function will be called with parameters.
License
*Note that all licence references and agreements mentioned in the SwiftRouter README section above
are relevant to that project's source code only.