Questions tagged [swinject]

Dependency injection framework for Swift

Dependency injection framework for Swift

70 questions
1
vote
1 answer

Swinject container registration fails

While trying to bind some protocols to various classes I have encountered a strange behaviour of getting nil in the protocols. This is the dependency injector class: class DependencyInjector: NSObject { let container: Container …
ironRoei
  • 2,049
  • 24
  • 45
1
vote
1 answer

UIViewController does not deinitialize (mvvm + coordinators)

I'm having a headache because of this issue. Why my SplashscreenViewController doesn't deinitialize? Do you guys see any potential retain cycles in the code posted below? I tried to check Malloc stack, but couldn't find any useful informations.…
Konrad Siemczyk
  • 186
  • 2
  • 9
1
vote
1 answer

Simple container bindings in Swift?

Disclaimer: I'm still learning Swift so forgive me if I haven't understood certain concepts/capabilities/limitations of Swift. With the Swinject framework, if you wanted to bind a protocol to a class - it seems you have to return the class instance…
Matt Inamdar
  • 136
  • 10
1
vote
1 answer

Swinject: Resolving using a list of metatypes

I'm trying to create a function to return an array of metatypes, which I can then use to resolve instances from a Swinject Resolver. Here's my code: protocol Task: class { } func getTypes() -> [Task.Type] { return [ConcreteTaskA.self,…
Mark
  • 7,167
  • 4
  • 44
  • 68
1
vote
2 answers

Swinject inject self's property into new UIViewController

Let's pretend we have an UITableViewController that on didSelectRowAtSection loads an instance of a class named i.e.: ClassToInject and it wants to inject it through a property injection because our ViewControllerToBePushed has a property of…
Jorge Revuelta
  • 822
  • 1
  • 8
  • 16
1
vote
0 answers

swinject - IOS - Swit - present a viewcontroller located in a xib file = crash

I use swinject with swift 3. I try to present on my current view controller, another view controller, located in a .xib file. if I do it in a project without swinject, it works. in my project, using swinject it crashes : libc++abi.dylib:…
1
vote
1 answer

Swinject for Swift 3.0.1

Currently Swinject/Swinject supports swift 3.0. When will it support swift 3.0.1? Anyone has any idea?
shoan
  • 1,303
  • 15
  • 22
1
vote
2 answers

Dependency injection inconsistency in differing ViewControllers in Swinject, post Swift 3.0 update: why?

I am registering some Swinject singleton-with-a-small-s (.container) services thus: defaultContainer.register( SomeService.self ) { _ in SomeService() }.inObjectScope( .container ) defaultContainer.register( AnotherService.self ) { …
Joseph Beuys' Mum
  • 2,395
  • 2
  • 24
  • 50
1
vote
1 answer

Swinject service class without parameters failing to register in .container scope with Swift 3.0: why?

I've created a super simple protocol: protocol IndependentProtocol {} and service: class IndependentService: IndependentProtocol {} and the following Swinject registration works: defaultContainer.register( IndependentProtocol.self ) { _ in…
Joseph Beuys' Mum
  • 2,395
  • 2
  • 24
  • 50
1
vote
1 answer

Combine Swinject and Realm

thanks for that Framework. I really like the idea and I'm eager to use it! However, I'm currently trying to get this up and running with an app that uses realm as well. I initially tought, It might be a good idea to create a realmService which I…
SantoDE
  • 33
  • 4
1
vote
0 answers

Does injecting factory make sense in this scenario (Swinject)

What is the right (cleanest and most concise) way to have PetOwner that can at any later point in program create new instances of Cat? Let's assume that createAnotherAnimal can be called by PetOwner itself after it gets response to some async…
deprivat
  • 11
  • 2
1
vote
1 answer

Swinject: migrating to assemblies

I'm using awesome Swinject for DI in my project, but I'm using it without assemblies (by the time I've started using Swinject, there was no assemblies). My current pattern of using Containers is: class ParentContainer { private let container:…
user1284151
  • 875
  • 4
  • 12
  • 23
1
vote
1 answer

Resolving a class of and object that conforms to protocol

I would like to pass an object that conforms to some protocol, and resolve its type for allocation with Swinject framwork (By dependency injection). protocol IViewModelAware { typealias T var viewModel : T { get set } } class…
MCMatan
  • 8,623
  • 6
  • 46
  • 85
0
votes
1 answer

Swinject error binding to date picker selection

I have a SwiftUI view that uses a date picker. I am trying to update my model via the date picker. The model is "Injected" via swinject, however I feel like something is slightly missing. The error is: Cannot convert value of type…
mickeysox
  • 159
  • 2
  • 14
0
votes
0 answers

Viper navigation using swinject assemblies

Currently i'm creating my modules like this: final class DiscoverAssembly { func build() -> UIViewController? { let container = Container() container.register(DiscoverInteractorInput.self) { (_, presenter: DiscoverPresenter)…
Bobby Redjeans
  • 575
  • 1
  • 4
  • 18