Latest 1.1.0
Homepage https://github.com/EMart86/SwiftDependencyInjection
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

SwiftDependencyInjection is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SwiftDependencyInjection"

Author

eberl_ma@gmx.at, martin.eberl@styria.com

License

SwiftDependencyInjection is available under the MIT license. See the LICENSE file for more info.

Usage

1) Implement a module:

import SwiftDependencyInjection

protocol FooProvider {
    var foo: Foo { get }
}

final class FooModule: Module, FooProvider {
    weak var delegate: ModuleDelegate?

    lazy var foo: Foo = {
        return Foo()
        }()
}

Use a protocol (here FooProvider) to help to communicate and request injection types.

2) Requesting the implementations of the protocol (e.g. in your ViewController or in any other module):

Injector.shared.inject(self)
.with(FooProvider.self)

This helps the injector to provide you the required dependencies. Add .with(…Provider.self) to request more dependencies.

3) Implement the Injectable protocol:

func inject<T>(inject: T) {
    if let inject = inject as? FooProvider {
        foo = inject.foo
    }
}

More samples are comming soon

Since we also have implemented some cyclomatic complexity, we’ll come back to you soon with an excample of how to use
Stay tuned!

Latest podspec

{
    "name": "SwiftDependencyInjection",
    "version": "1.1.0",
    "summary": "A dependency Injection Framework in Swift",
    "description": "Have you ever struggled withe dependency injection framework in swift. Here is one, that's based on dagger. You have modules, you have injectors that provides you with the modules, you require in your code. We also did some dependency resolving in our modules. Now let's get swifty.",
    "homepage": "https://github.com/EMart86/SwiftDependencyInjection",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "eberl_ma@gmx.at": "martin.eberl@styria.com"
    },
    "source": {
        "git": "https://github.com/EMart86/SwiftDependencyInjection.git",
        "tag": "1.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SwiftDependencyInjection/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This