Skip to content

RefdsInjection is a Swift library that provides a simple yet powerful solution for dependency injection in your iOS, macOS, and other Swift applications. With RefdsInjection, you can manage your components' dependencies cleanly and efficiently, easing the development, testing, and maintenance of your codebase.

License

Notifications You must be signed in to change notification settings

rafaelesantos/refds-injection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Refds Injection

Swift

RefdsInjection is a Swift library that provides a simple yet powerful solution for dependency injection in your iOS, macOS, and other Swift applications. With RefdsInjection, you can manage your components' dependencies cleanly and efficiently, easing the development, testing, and maintenance of your codebase.

Installation

Add this project to your Package.swift file.

import PackageDescription

let package = Package(
    dependencies: [
        .package(url: "https://github.com/rafaelesantos/refds-injection.git", branch: "main")
    ],
    targets: [
        .target(
            name: "YourProject",
            dependencies: [
                .product(
                    name: "RefdsInjection",
                    package: "refds-injection"),
            ]),
    ]
)

Usage

import RefdsInjection

protocol MockViewModelProtocol {
    var id: UUID { get }
}

class MockViewModel: MockViewModelProtocol {
    var id: UUID
    init(id: UUID) { self.id = id }
}

let expectedID = UUID()
RefdsContainer.register(type: MockViewModelProtocol.self) { MockViewModel(id: expectedID) }
let viewModel = RefdsContainer.resolve(type: MockViewModelProtocol.self)
let receivedID = viewModel.id

About

RefdsInjection is a Swift library that provides a simple yet powerful solution for dependency injection in your iOS, macOS, and other Swift applications. With RefdsInjection, you can manage your components' dependencies cleanly and efficiently, easing the development, testing, and maintenance of your codebase.

Topics

Resources

License

Stars

Watchers

Forks

Languages