https://github.com/kibotu/khan
Khan is to iOS what androidx.startup is to android.
https://github.com/kibotu/khan
dependency initialization ios startup swift
Last synced: 3 months ago
JSON representation
Khan is to iOS what androidx.startup is to android.
- Host: GitHub
- URL: https://github.com/kibotu/khan
- Owner: kibotu
- License: apache-2.0
- Created: 2024-07-01T07:13:40.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-07-17T14:03:39.000Z (over 1 year ago)
- Last Synced: 2025-01-21T21:35:29.007Z (about 1 year ago)
- Topics: dependency, initialization, ios, startup, swift
- Language: Swift
- Homepage:
- Size: 12.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Khan for iOS
[](https://github.com/kibotu/Khan/actions/workflows/build-swift.yml) [](https://github.com/kibotu/Khan/releases) 
[](https://support.apple.com/en-us/101566)
[](https://www.swift.org/blog/swift-5.10-released/)
Khan is a robust dependency management and initialization system for modular app components in Swift.
### Key Features
- Automated dependency resolution and initialization
- Circular dependency detection
- Comprehensive logging for debugging
- Debug mode shuffling to detect order-dependent issues
### Setup
1. Add the Khan framework to your project.
2. Create initializers for your app components:
```swift
class DatabaseInitializer: Initializer {
static var dependencies: [Initializer.Type] = []
static func embark() async throws {
// Initialize database
}
}
```
### Usage
1. Create a Khan instance with your initializers:
```swift
let initializers: [Initializer.Type] = [
DatabaseInitializer.self,
NetworkingInitializer.self,
// Add other initializers
]
do {
let khan = try Khan(initializers: initializers)
try await khan.conquer()
} catch {
print("Initialization failed: \(error)")
}
```
2. Khan will automatically resolve dependencies and initialize components in the correct order.
Options
- `enableLogging`: Toggle logging on/off (default: true)
### Advanced Usage
For complex dependency graphs, use `khan.printDependencyTree()` to visualize the initialization order.
## How to install
### Swift Package Manager
Add the dependency to your `Package.swift`
```swift
products: [
...
]
dependencies: [
.package(url: "https://github.com/kibotu/Khan", from: "1.0.0"),
],
targets: [
...
]
```
## Requirements
- iOS 16.0 or later
- Xcode 15.0 or later
- Swift 5.10 or later
Contributions welcome!
### License
Copyright 2024 Jan Rabe & CHECK24
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.