johnno1962 / InjectionIII

Re-write of Injection for Xcode in (mostly) Swift
MIT License
4.02k stars 319 forks source link

[NSDictionaryM setObject:forKeyedSubscript:] issue #64

Closed JeaSungLEE closed 5 years ago

JeaSungLEE commented 5 years ago

I want to apply injectionIII to my project.

Xcode10 Swift4.2

Re-compilation failed error: no such module The above error is occurring.

I think I am having problems using Carthage and how can I fix it?

zenangst commented 5 years ago

Hey @JeaSungLEE, mind sharing some additional information about your project? What kind of class are you trying to inject? Does it fail on all files? Do you have any additional logs than the log statement that you provided in the issue description?

JeaSungLEE commented 5 years ago

Hi The above problem was my project problem. I removed the framework from the project and re-imported it.

     @objc func injected () {
     }

But now, when I save it in the ViewController with the above code, there is an error in appdelegate (there is no code in the injected function). There is no other log, so I can not solve it. Do you have any guesses about why this crash happens?

Please refer to the picture below.

image
JeaSungLEE commented 5 years ago

Problem reloading nib: *** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil And after rebuilding the storyboard, the above logs are shown. What's the problem with this?

zenangst commented 5 years ago

From what I can gather from the stack trace, this looks like recursion.

So your view controller uses a storyboard, is that correct? Would you mind providing an example project that we can test this with, having an isolated test case usually helps to narrow things down and come up with a fix :)

zenangst commented 5 years ago

@JeaSungLEE with regard to the error message that you posted:

Problem reloading nib: *** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil

I dug into the code and found that in some scenarios, the injection method for storyboards cannot always resolve the currently visible view controller. I've made a PR to improve the search pattern for the current view controller on screen by adding a case for when you use a navigation controller.

You can find the PR here #76

Mind sharing a bit more information about your applications view controller stack to see if it covers your scenario as well?

zenangst commented 5 years ago

@JeaSungLEE hey mate, do you still have these issues with the latest version of InjectionIII?

JeaSungLEE commented 5 years ago

Sorry to check this issue too late. Tried it and it did not matter. Thank you very much for giving a lot of care.

I will close the issue.