ComposableDeepLink – is a Swift DSL library for handling deep links in a composable and flexible way.
It provides an approach to deep link processing, allowing you to define complex deep link handling logic using a composition of smaller components.
- Composable handlers for:
- schemes
- hosts
- paths
- parameters
- Support for static and parameterized paths.
- Easy-to-use syntax for defining deep link handling logic.
You can integrate ComposableDeepLink into your project using:
- Swift Package Manager (SPM)
- Add the following dependency to your
Package.swift
.package(url: "https://github.com/xxKRASHxx/composable-deep-link", from: "0.2.0")
- add
ComposableDeepLink
to your target's dependencies.
- Add the following dependency to your
- Xcode project
- From the File menu, select Add Packages...
- Enter "https://github.com/xxKRASHxx/composable-deep-link" into the package repository URL text field
- Import library to the reqired target
Here's a simple example demonstrating how to use ComposableDeepLink to handle deep links:
import ComposableDeepLink // 1. Import Library
enum DeepLink { // 2. Define result type
case foo(id: String)
case bar
case biz
}
let processor = ComposableDeepLink<DeepLink> { // 3. Compose handling
Scheme("myapp") {
Host("example.host.com") {
Path("/foo/:id") { context in
Handle { // Handle the deep link logic here
guard let id = context.id else { return nil }
return .foo(id: id)
}
}
}
Host("another.host.com") {
Path("/bar") { context in
Handle { // Handle the deep link logic here
.bar
}
}
Path("/bar/biz") { context in
Handle { // Handle the deep link logic here
.biz
}
}
}
}
}
if let result = processor.handle(url: deepLinkURL) {
// 4. Do something with the result
}
Contributions are welcome!
If you have any suggestions, feature requests, or bug reports, please open an issue or submit a pull request
ComposableDeepLink is available under the MIT license.
See the LICENSE file for more information.