Swinject / SwinjectStoryboard

Swinject extension for automatic dependency injection via Storyboard
MIT License
267 stars 144 forks source link

OSX | HighSierra | Doesn't invoke storyboardInitCompleted #69

Closed dukhovnyi closed 6 years ago

dukhovnyi commented 7 years ago

Hi guys,

I have been using SwinjectStoryboard for a long time and didn't have any issues. Now I have some problem with High Sierra and want to know maybe you have some solution for this issue. After latest changes (tag 1.1.2) setup() class method is invoke, but doesn't invoke closure in storyboardInitCompleted method. I've checked problem and found the method swinject_storyboardWithName:bundle: that not invoke.

yoichitgy commented 7 years ago

Thanks @dukhovnyi for posting the issue. Does v1.1.1 reproduce the issue? Or only v1.1.2 has the issue?

dukhovnyi commented 7 years ago

v1.1.1 had the issue related to +initialize method and in v1.1.2 it's not reproduced, so I can't check this issue in v1.1.1.

dukhovnyi commented 7 years ago

@yoichitgy I've made experiment and want to share it with you. I made two equal classes on Swift and Objective-C. Each one is subclass of NSStoryboard and has by 2 methods. First method sayHello - print in console "Hello" Second method invoke storyboardWithName:bundle: Result of invocation method on Sierra and HighSierra are different.

Screenshots and sample project are below.

Storyboard-Swift-vs-ObjC.zip

macos 10 13b7 2017-08-28 18-46-36

Sierra appdelegate swift 2017-08-28 18-48-38

HighSierra macos 10 13b7 2017-08-28 18-48-17

yoichitgy commented 7 years ago

Thanks @dukhovnyiđź‘Ť Let me investigate the issue.

filippovdev commented 7 years ago

@yoichitgy the same issue after migrating to Xcode 9 (on Sierra), storyboardInitCompleted doesn't invoke :( SwinjectStoryboard 1.1.2

filippovdev commented 7 years ago

@yoichitgy Hi, any news about fixes for this issue ? It is very important for us. Hm what is interesting. When I run my project on Xcode 8 everything works fine, but when I open it with Xcode 9, compile, close and open again in Xcode 8 it has completely the same issue, doesn't invoke storyboardInitCompleted O_O.

dukhovnyi commented 7 years ago

Hi guys, I’ve made sample for demonstrate problem with NSStoryboard. The main problem in subclassing of NSStoryboard, you can’t use storyboardWithName:bunlde: anymore, because this method makes instance of NSStoryboard, not your custom subclass of NSStoryboard, like as SwinjectStoryboard. So SwinjectSotryboard won’t work on macOS 10.13+ with current realization. For solving this issue in my project I’m using Swinject.

mlloyd commented 7 years ago

hey, I just ported a code base to a new Xcode 9 project.. and.. I also saw that storyboardInitCompleted and SwinjectStoryboard.setup() wasn't invoked. I noticed that SWIFT_SWIFT3_OBJC_INFERENCE was set to default. I change this to On. And everything worked. Have you tried this?

yoichitgy commented 7 years ago

Thanks @mlloyd for sharing the workaround with SWIFT_SWIFT3_OBJC_INFERENCE. I've not tried it yet. I'll tryđź‘Ť

kreeger commented 7 years ago

@mlloyd @yoichitgy Did you set that value to On for the application you're running? Or for Swinject/SwinjectStoryboard? I can't seem to get that property to fix anything no matter what it's set to.

arnaud512 commented 7 years ago

Same problem. I tried SWIFT_SWIFT3_OBJC_INFERENCE = on for the Main project and for the Pods but none of both are working.

Thread 1: EXC_BAD_ACCESS (code=2, address=0x7fffa6dc2d48) in SwinjectStoryboard.swift:create() at line 73: storyboard.container = Box(container)

yoichitgy commented 7 years ago

I still didn't try SWIFT_SWIFT3_OBJC_INFERENCE on. I'll check it in November.

jakubvano commented 6 years ago

I've been unable to reproduce the problem - do you guys still observe this issue, or has it been fixed by new version of tools? My env: OSX 10.13.3, Xcode 9.2, Cocoapods 1.4.0, Carthage 0.28.0

@dukhovnyi also, your project gives me the same output on OSX 10.13.3 as it gave on Sierra

kreeger commented 6 years ago

@jakubvano Lemme fire up my code that uses this and find out.

jakubvano commented 6 years ago

Proper support for Swift4 with iOS / OSX has been introduced in 2.0.0.-beta.1.

Feel free to reopen this if issue still persists

alexito4 commented 6 years ago

I think this is still happening in 2.0.2 (with frameworks or static lib). The swizzling code in + (void)load gets executed, going trough the method_exchangeImplementations branch, but then the swizzled code never gets executed, which makes the approach of using it with the default Main.storyboard not work. Any clue on what can be going on?