CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate CarbonGraph into your Xcode project using CocoaPods, specify it in your Podfile:
pod ‘CarbonCore’, ‘~> 1.3.3’
Quick Start
Basic object registration and resolving
let context = ObjectContext()
let definitionBuilder = Definition("filevc")
.protocol(UIViewController.self)
.object(FileViewController())
context.register(builder: definitionBuilder)
context[UIViewController.self, name: "filevc"]
let context = ObjectContext()
let definitionBuilder = Definition()
.object(FileManager() as FileManagerProtocol)
context.register(builder: definitionBuilder)
context[FileManagerProtocol.self]
Use configuration batch registration
```swift
class MyConfiguration: Configuration {
static func definitions(of context: ObjectContext) -> Definitions {
let context = ObjectContext()
context.register(configuration: MyConfiguration.self)
context[FileModel.self]
## Basic usage
> Note: For convenience, the registration of object definitions and the creation of context that appear in the following will be omitted. All definitions in your project must be registered before they can be resolved.
* Use constructor for dependency injection
```swift
Definition()
.protocol(FileViewControllerProtocol.self)
.constructor(FileViewController.init(fileManager:))
context[FileViewControllerProtocol.self].fileManager
The same as:
```swift
Definition()
.factory { context in
let fileVC = FileViewController()
fileVC.fileManager = context[FileManagerProtocol]
return fileVC as FileViewControllerProtocol
}
For more information see [Basic usage](/mirrors/CarbonGraph/tree/main/CarbonCore/CarbonCore/CarbonCore.docc/BasicUsage.md)
## Documentation
The documentation of this project is written in [DocC](https://developer.apple.com/documentation/docc), please clone the repo and build the documentation yourself.
1. Clone this repo
2. Open Carbon.xcworkspace with Xcode
3. Product > Build Documentation
For more information see Unit Test and Example
## Contribution
You are more than welcome to contribute code to the project,for more information see [Contribution](/mirrors/CarbonGraph/tree/main/CarbonCore/CarbonCore/CarbonCore.docc/Contribution.md). You can also join the WeChat discussion group, check the QR code below.
<a href="https://weixin.qq.com/g/AQYAAMrdukzdvyo_JJrKIVjcJXhKFS2Of8v1P6K3bQIIwZ28E1BWAcsfbGWFKEHs"><img width="360" src="https://www.gitlink.org.cn/api/mirrors/CarbonGraph/raw/CarbonCore/CarbonCore/CarbonCore.docc/Resources/wechat_qr_code.jpg?ref=main"></a>
## License
CarbonGraph is released under the MIT license. See [LICENSE](./LICENSE) for details.
CarbonGraph is a Swift dependency injection / lookup framework for iOS. You can use it to build loose coupling between modules.
The CarbonGraph project contains 2 frameworks:
Features
Requirements
For more information see Compatibility
Installation
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate CarbonGraph into your Xcode project using CocoaPods, specify it in your Podfile:
Quick Start
let context = ObjectContext() context.register(configuration: MyConfiguration.self) context[FileModel.self]
Use property for dependency injection
Use setter for dependency injection
Use static factory for manual dependency injection ```swift Definition() .factory(fileViewController(context:)) context[FileViewControllerProtocol.self].fileManager
static func fileViewController(context: ObjectContext) -> FileViewControllerProtocol { let fileVC = FileViewController() fileVC.fileManager = context[FileManagerProtocol] return fileVC }
static func fileModel(context: ObjectContext, path: String, name: String) -> FileModelProtocol { FileModel(path: path, name: name) }