Comments (16)
Hi, you seem to have a couple of issues mixed into one. Firstly, injection only updates function implementations but the new implementations are not re-called automatically. So, it cannot arrange for your ViewController to redraw and update the display on its own; You need to use one of the techniques described in the project README. That aside, inherited methods, particularly across modules is a tricky problem and you may have run across a limitation. Remember though, when injecting an inherited method remember to inject the superclass then inject the subclass again so it gets a change to update the subclass' vtable if you want to see it work.
from injectioniii.
My issue is completely unrelated to calling any methods, I know that. I just wanted to make clear how this specific architecture looks like.
I only expect a ViewControllers viewDidLoad()
method to be re-executed because of the extension mentioned in the README
#if DEBUG
extension UIViewController {
@objc func injected() {
viewDidLoad()
}
}
#endif
However, the viewDidLoad()
is not executed when using those types from another module.
Unfortunately in my context adding a library to production code is not an option, so I am only able to load InjectionIII's bundle in AppDelegate
, add the extension and the linker flags to the example project.
Have you got any further suggestion or am I maybe missing something?
from injectioniii.
Let's separate this into two problems. Are you saying the injected() method you add in your example project dependant on a pod containing the ViewControllers you're using isn't called? That would be unusual. Leave the sayHi() method to one side for a second.
from injectioniii.
yeah exactly. I updated the code to reduce confusion. There's no issue with calling any inherited methods whatsoever.
My only problem is that I need to go back and push the ViewController again to see the changes
from injectioniii.
I can see how that might happen though I need to think about it some more. The problem won't be with the @objc injected()
method but the dispatch of the viewDidLoad()
through the vtable(s). Recapping, which "the" ViewController do you need to push again to see the changes? If you see the changes, how does this not meet your expectations?
from injectioniii.
I need to push the TestViewController
again (the one I am working on).
However, if at runtime I change TestViewController
the following way, then my changes within viewDidLoad()
update right-away.
class TestViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemGreen // changes are updated automatically in Simulator
}
}
from injectioniii.
So if TestViewController inherits UIViewController directly it works but if it inherits MyViewControllerBase it doesn't?
from injectioniii.
exactly!
from injectioniii.
Unfortunately I cannot share the code with you. But maybe I find some time in the coming days to reproduce this in a sample project set up with cocoapods.
But I think now you're understanding my problem.
from injectioniii.
Very strange, I may take a look tomorrow if I can think of something fixable. It would be very helpful to me if you were able to prepare a small project demoing the problem.
from injectioniii.
Sure, but give me some days! You can also wait to not waste your time in case my problem lays somewhere else and I don't manage to reproduce it
from injectioniii.
Thanks! That would be very helpful; no hurry. By the way, I don't have Cocoapods installed on my machine but you should be able to replicate your problem by putting your superclasses in a framework target which is what Cocoapods does anyway.
from injectioniii.
Just a thought. Have you tried adding the injected() method to your TestViewController?
@objc func injected() {
viewDidLoad()
}
from injectioniii.
Hi, I've tried a few things with a test project and not been able to replicate this problem. If you get a change to produce a small example app that shows the problem but doesn't use Cocoapods and post it here or email it to me via github at johnholdsworth.com I can take a look at it for you.
from injectioniii.
Just a thought. Have you tried adding the injected() method to your TestViewController?
@objc func injected() { viewDidLoad() }
Yeah I tried that and it made no difference. It recognizes that I'd need to override it and when changing the extension from UIViewController
to be on TestViewController
instead, it still doesn't execute the viewDidLoad()
from injectioniii.
Hi, I've tried a few things with a test project and not been able to replicate this problem. If you get a change to produce a small example app that shows the problem but doesn't use Cocoapods and post it here or email it to me via github at johnholdsworth.com I can take a look at it for you.
Just spent some hours vaguely recreating the setup first with just two modules and that worked as you have stated already.
Then I tried to setup a comparable cocoapods environment and that also works fine. So the issue might be something different and I'll see if I casually find out what is causing it in the coming weeks.
So I guess we can close this issue for now and we'll see if I come back with a solution.
Thank you very much for your assistance!
from injectioniii.
Related Issues (20)
- Fatal error: NSArray element failed to match the Swift Array Element type HOT 1
- EXC_BAD_ACCESS after add var in swift class HOT 2
- Injection doesn't work with Xcode 15.2 HOT 10
- Multiple frameworks/targets issue HOT 3
- error: no such module 'FirebaseFirestoreInternalWrapper' HOT 4
- Error loading, when using mac target HOT 3
- Crash on reload every time HOT 6
- Loading .dylib has failed HOT 15
- EOF received from server.. HOT 2
- Setting up for macOS app dev HOT 21
- Is there a way to make injected macOS app not become active when it's reloaded? HOT 2
- Re-compilation failed HOT 5
- InjectionClient/Could not connect: Connection refused 🔥 HOT 18
- Hello, I reported the error when I used the real machine to debug, looking forward to your answer, thank you HOT 6
- Meaning of colors HOT 2
- It doesn't work on Xcode 15.3 iOS 17.4 HOT 14
- It doesn't work on xcode 15.3 (15E204a) HOT 7
- Loading .dylib has failed HOT 1
- TCA ObservableState crash HOT 3
- Unknown argument: -interposable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from injectioniii.