Questions tagged [swinject]

Dependency injection framework for Swift

Dependency injection framework for Swift

70 questions
0
votes
0 answers

Swinject fails on app start for some of our users starting from Xcode 14.0, 14.0.1

We use Swinject 2.8.0 and 2.8.2 in our app from the pod and we see that some of our users (100-200 crashes) have problems with the app. I could not reproduce the issue any of our test devices like 20 iPhones. So the app crashes right at the first…
Mr. G
  • 405
  • 4
  • 6
0
votes
0 answers

Swinject always return nil when trying to resolve any object

I have the following Swinject implementation in my app - import Foundation import Swinject @propertyWrapper struct Inject { let wrappedValue: Component init() { self.wrappedValue = Resolver.shared.resolve(Component.self) …
Alon Shlider
  • 1,187
  • 1
  • 16
  • 46
0
votes
0 answers

How to resolve from other modules in Swinject

Modularized the project using Tuist. I made RepositoryAssembly and UseCaseAssembly on the Data module and Domain module. Assembler is located in InjectManager and runs in AppDelegate in the App module. // InjectManager.swift public struct…
baegteun
  • 3
  • 2
0
votes
0 answers

Passing Objects between ViewModels in MVVM-C with Dependency Injection (Swinject)

I am new to DependencyInjection and Swinject and because of that i have question. Let's say we have a ViewModel PersonList with a list of Person objects. We select one of the Person and pass it to PersonDetails which is something like…
dev_ios999
  • 339
  • 3
  • 9
0
votes
3 answers

Swinject returns nil because object is wrong registered

This is how I register object for FirebaseMessaging: container.register(Messaging.self) { _ in return Messaging.messaging() } and then I need to use it: container.register(NotificationSchedulerable.self) { resolver in …
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
0
votes
1 answer

Stuck with storyboards control under swinject environment

Hi I am trying to apply swinject for my IOS project and currently I have been stuck.. I have 2 part in my application LOGIN Part MAIN Part Scenario is if it's logged in already when application begins or when login is successfully done, it should…
0
votes
2 answers

What am I Doing wrong in Swinject?

Whenever I run this code the init() of the VCModel gets called but Swinject is not Injecting the VCModel instance to my ViewController. Can Someone Please tell me what am I doing wrong? Error I get is: Unexpectedly Found nil while unwrapping an…
0
votes
1 answer

How to resolve dependencies swinject (without storyboard), where is another important controller taken as rootVC?

I dont have storyboard in my app. So all my dependencies spelled out in App Delegate. I read the documentation of the Swinject and there the option is suggested: window.rootViewController = container.resolve(PersonViewController.self) But in my…
0
votes
1 answer

Swinject: How to use delegate pattern with interface segregation (class vs interface)?

I'm working my way into the injection dependency issue. Now the question arises how to use the interface segregation principle in the case of the delegate pattern? I am using the Swinject framework for dependency injection. How can I solve…
Tyrus Rechs
  • 73
  • 2
  • 12
0
votes
1 answer

Inject dependencies in xib controller

I'm developing a macOS application that only consists of a menu bar icon. I have a xib file (MenuBarMenu.xib) with the menu and a corresponding controller(MenuBarMenuController.swift) that puts it in menubar. I want to inject dependencies in this…
undsoft
  • 789
  • 2
  • 12
  • 21
0
votes
2 answers

Swift func with generic where constraint is a protocol which self conforms

I'm trying to write a static generic method which takes a protocol as an argument and register class instance in Swinject container as a protocol resolve. It's important that I could not register a module as a protocol it does not conforms to. I…
Vladlex
  • 845
  • 8
  • 16
0
votes
1 answer

Possible to register static only protocols?

Unfortunately, some libraries only have static methods to them. Is it possible to make Swinject register a type to return a type instead of an instance of a type? Makes it hard to stub out static only libraries for testing.
moger777
  • 1,117
  • 11
  • 16
0
votes
0 answers

Passing data from modal to presenting vc using Swinject+Assembly

I'm working on a project using RxSwift + Swinject + Assembly but they are quite new to me. I'm having a modal controller for filters selection. It uses FilterViewModel with all available filters. I'm wondering how to pass selected filters to…
Magda
  • 81
  • 1
  • 5
0
votes
3 answers

Swinject - how to resolve the same controller twice from one resolver?

import Swinject class GenericsAssembly: Assembly { func assemble(container: Container) { container.register(TabBarController.self) { resolver in let split1 = resolver.resolve(SplitViewController.self)! let split2…
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
0
votes
1 answer

SwinjectStoryboard - Is it possible to load / inject a storyboard that its ViewController exists within a different framework in another project?

SwinjectStoryboard - Is it possible to load / inject a storyboard that its ViewController exists within a different framework in another project?
Wael
  • 489
  • 6
  • 19