Comments (23)
Where is MyProtocol defined? Is it in its own file or is it being injected as well? Or, you could also try setting the environment variable INJECTION_DYNAMIC_CAST in your scheme.
from inject.
It's In it's own file
Will try with env var now and let you know
P.S. Thanks for such fast reply!
from inject.
unfortunately it didn't help
from inject.
Any chance of a small example project so I could look into what's going on?
from inject.
Yes
Let me try to construct one
from inject.
Here is a sample project
https://github.com/romaHerman/InjectTest
It has TestComponents xCodeProject and main xCodeProject
in SceneDelegate you can find test invocations of methods
it's similar to my setup in main project
from inject.
Thanks for the example project. Injection aside, I can see that Inject.ViewControllerHost(CalendarViewController())
has type Inject._ViewControllerHost<CalendarViewController>
not CalendarViewController
which even though it is defined as a subclass of CalendarViewController does not acquire the conformance to TestProtocol
. This seems to be a Swift thing. @krzysztofzablocki?
from inject.
... Perhaps you need to do something like:
if let vc = vc.instance as? TestProtocol {
vc.testPrint()
}
from inject.
Thanks!
It does work in this case with vc.TestPrint()
but unfortunately it won't solve problem with passing this view to side menu
I have SideMenu which does navigationController.pushViewcontroller(<VC>)
and in order Inject to work in should push vc
not vc.instance
problem is here
let calendar = Inject.ViewControllerHost(CalendarViewController())
sideMenu.view = calendar.instance
from inject.
How do you mean "for inject to work"? If you save the file containing CalendarViewController, its methods will have been overridden for the next time they are called again.
from inject.
here is what I'm trying to do
let calendar = Inject.ViewControllerHost(CalendarViewController())
viewControllers = [NewsViewController(), calendar.instance]
menu.viewcontrollers = viewControllers
inside menu viewControllers variable is declared like this
var viewControllers: [MenuProtocol] = []
and when I do
menu.selectedIndex = 1
inside it does following
navigationController.setViewcontrollers[viewControllers[selectedIndex]
so it sets calendar.instance not the calendar itself and I think this the problem why Inject doesn't hot reload it for me
from inject.
It's possible the "Hosting" model Inject uses may not be for you in this instance. When you save the file containing NewsViewController it will have been "swizzled" correctly. Perhaps you just need a way to force it to redraw. Have you looked at creating an `@objc func injected()' method which should be called when the class is injected inside which you call viewDidLoad() or configure() or something to force the redraw so you can see the hot reload.
from inject.
Thanks
I've overlooked this
How I can do that ?
from inject.
create an @objc func injected()
function in your class and see if it gets called. If it does, then you can do some stuff in it.
from inject.
Maybe I will have to change SideMenu somehow to accept viewControllers
injected doesn't get called
from inject.
I can zoom if you get stuck.
from inject.
wow, thanks a lot!
if it works for you I'm ready
Tell me when you have time for that
from inject.
Or TeamView. Send an invite/login to github at johnholdsworth.com
from inject.
Actually, TeamView if you can thanks.
from inject.
well
I've changed my setup and now I don't need to solve this problem but somehow InjectionIII just quit working
I can see
InjectionIII connected /Users//Documents/App.xcworkspace
and when I open debug view hierarchy in Xcode I can sett that there is InjectionHostVC
also I gave access to all files and folders in mac's security
But when I change view and save nothing happens
I've tried reinstalling app and installing again, installing from Mac App Store and also restarting Mac
from inject.
You seem to be watching the workspace file instead of watching the directory containing the workspace file. Use menu item "Open Project" to set it again.
from inject.
Ohhh
I somehow thought that I should select workspace
It's working now
Thanks a lot!!!
BTW here is how I hacked thing that I can't add this view to menu directly because of protocol
added this line in viewWillAppear so view controller will re-instantiate itself and thus re-add itself with Injected host
I will have to remove this code once I'm done working with this VC but it solves the issue
if injectSelf {
let eventVC = Inject.ViewControllerHost(EventsViewController())
eventVC.injectSelf = false
navigationController?.setViewControllers([eventVC], animated: false)
}
from inject.
for passing specific type only .instance
can work, but in that scenario I'd recommend probably not commiting host changes, I usually just do host swap in separate commit I can easily delete at the end of feature work
from inject.
Related Issues (20)
- Not working in device HOT 1
- New version/tag HOT 1
- On device flags compilation failure HOT 1
- UISearchBar Doesn't Show with UINavigationController + Inject.ViewControllerHost HOT 1
- Upload to cocoapods HOT 1
- How to use it with .xib or .storyboard? HOT 1
- Ability to subclass Inject.ViewControllerHost HOT 1
- Not working in AppCode HOT 9
- Trigger update when non source code file changes HOT 1
- Debug View Hierarchy stops working after compiling a new ViewController HOT 2
- Inject on multi frameworks project HOT 4
- Device injection HOT 8
- Injection is not working Xcode 14.0.1 HOT 3
- InjectionIII connected but view doesn't reload HOT 9
- SwiftUI + UIKit project causes crashes HOT 12
- Interface Builder and prepare for segue HOT 4
- / HOT 1
- Could not find module for target 'x86_64-apple-ios-simulator' HOT 11
- Xcode package integration not working HOT 4
- Only add on root view (SwiftUI) HOT 3
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 inject.