AliSoftware/Dip-UI

Swift 3 problem

JanBorowskiES opened this issue · 4 comments

Hello,

I saw thread "Swift 3 issues" in Issues page of Dip library and I am wondering whether problems mentioned there applies also to DipUI library. Since I updated library to version 1.0.0, I am experiencing problem when instantiating controller from storyboard with DipUI.
Here is sample code for container controller registration:

container.register(tag: "ViewController") {
            ViewController()
            } .resolvingProperties { (container, entity) in
            entity.viewModel = try! container.resolve() as ViewModel
        }

I have storyboard with viewController with dipTag "ViewController". When I try to instantiate VC, following error occurs:
fatal error: attempt to bridge an implicitly unwrapped optional containing nil
in line 46 in AutoInjection.swift in Dip library.

Has any one found solution for this? Or should we wait for Swift 3.1? This method worked with Swift 2.3 and DipUI 0.2.2

tl;dr . I've digged deeper and with workarounds I am able to use Dip & DipUI in swift 3.0 . Those reflection bugs are really annoying...

Yes, those bugs will affect you if you use DipUI too, as in fact you will use Dip to resolve dependencies. To workaround you may make outlets optionals instead of IUO

@JanBorowskiES good news are that first issue is not happening any more in Xcode 8 GM. Bad news are that the second one is still there. So I've just hot patched auto-injection to avoid accessing IUO properties. So it should be possible to use IUO again for outlets after it is merged (AliSoftware/Dip#125)

Thanks :). Good to know that a least some functionality has been recovered.