Questions tagged [swinject]

Dependency injection framework for Swift

Dependency injection framework for Swift

70 questions
7
votes
3 answers

How do I pass arguments to the resolve method when using Swinject?

I have a test project that I'm trying to pass an argument to the resolve method in a Swinject project. Here is an example of what my Swinject storyboard extetion file has in it. import Swinject extension SwinjectStoryboard { class func…
mattwallace
  • 4,132
  • 6
  • 43
  • 77
4
votes
1 answer

Does swinject re instantiate the object?

I have a question, I'm using Swinject in a separate framework. My app get the object from this framework and my appExtension use it too. But in the Extension the Object is not correctly instantiate. Does Swinject use the first instance of my object…
Max0u
  • 691
  • 1
  • 9
  • 21
4
votes
2 answers

Swinject register UIViewController best practice

At this point in my project I use Swinject (DI Container). I want to know how to register the ViewController, if I have the following hierarchy: class RateAnswersBaseVC: UIViewController { } class RateAnswersDoctorVC: RateAnswersBaseVC { } class…
4
votes
1 answer

Swinject - Ambiguous reference to member

I am using Swinject in my Swift 3 app. When I tried let container = Container() container.register(NetworkModeling.self) { _ in Network() } I get an error saying Ambiguous reference to member 'register(_:name:factory:)' What is wrong here?
Jaseem Abbas
  • 5,028
  • 6
  • 48
  • 73
4
votes
1 answer

Using Swinject to inject a Model class instance into a View class instance in Swift

In a Swift 2.0, Single Page Application project, in XCode 7.0.1, with the Swift dependency injection framework Swinject, I am doing the following: DuplicateProtocol.swift: protocol DuplicateProtocol { var id: String { get }…
Joseph Beuys' Mum
  • 2,395
  • 2
  • 24
  • 50
3
votes
1 answer

How to use Swinject to register protocol conforming to ObservableObject?

Right now, I've been running into an issue of registering protocol conforming to ObservableObject. Since ObservableObject uses an associated type, I cannot find a way to register it without compiling error. This is my simple model, called A protocol…
3
votes
0 answers

How to inject viewModel class into WKInterfaceController?

I'm trying to inject my viewModel class to WKInterfaceController, in my InterfaceController I have set property but when I try to use it in func awake(withContext context: Any?), it's nil. So the way I was trying to do it: setting up the container…
3
votes
1 answer

Circular dependency issue with Swinject

I'm using Swinject in my Swift iOS app and try doing a circular dependency as explained on the official documentation page: https://github.com/Swinject/Swinject/blob/master/Documentation/CircularDependencies.md I've copied the code from the circular…
CyberDude
  • 8,541
  • 5
  • 29
  • 47
2
votes
0 answers

UIScrollView bar insets the size of the tab bar and nav bar

I am using the library Chatto (https://github.com/badoo/Chatto) for a chat window and initializing a view controller that inherits from it's BaseChatViewController. The issue that i'm having is that while the scroll view can scroll all the way to…
Brandt
  • 333
  • 3
  • 11
2
votes
0 answers

Swinject: Resolution failed when using multiple modules (projects) in workspace

I am trying to setup DI for multi-module workspace with Swinject. I have one ParentProject where I embed binary framework built from ChildProject (so ParentProject includes all public code from ChildProject). My approach is to create one Assembly…
2
votes
2 answers

How to inject the right viewModel to a single viewController

I'm using Swinject for my DI solution, and extend it with the SwinjectStoryboard extension. I'm struggling with dynamic injecting the right viewModel to a specific viewContoller. The specific scenario is as follow: MyViewController has a property…
goldengil
  • 1,007
  • 9
  • 25
2
votes
3 answers

Crash: Container.swift line 299 Container.resolve (entry : ServiceEntryProtocol, invoker : (B) -> Any) -> A?

Recently I have started getting crash when trying to resolve an object. Following is the crash logs. I can see that in Container.swift at line 299 guard let currentObjectGraph = currentObjectGraph else { fatalError() } the application is not…
Balraj Singh
  • 3,381
  • 6
  • 47
  • 82
2
votes
0 answers

Shared container with assembly - how to pass same objects to Coordinator and Controller

Everytime we resolve a protocol/class then we get a new object. My coordinator needs a view model and my controller needs the same view model. internal class LoginFactory: Assembly { func assemble(container: Container) { let delegate =…
A_G
  • 2,260
  • 3
  • 23
  • 56
2
votes
1 answer

Is using assembly with container worth it?

I am using Swinject for Dependency Injection. I have created a DependencyManager which has a shared instance of container. internal class DependencyManager { private static let sharedInstance = DependencyManager() private var assembler:…
A_G
  • 2,260
  • 3
  • 23
  • 56
2
votes
1 answer

Share object instance between objects with Swinject

I am starting to use Swinject in my apps and I want to share an instance of my rootNavigator between presenters(Viper/MVP) or viewControllers(Not Viper). The main problem that I have is that I want to share appRootNavigator in presenters, but I…
croigsalvador
  • 1,993
  • 2
  • 24
  • 47
1
2 3 4 5