Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There's no way to show it #101

Closed
CreatSuns opened this issue Jan 24, 2019 · 5 comments
Closed

There's no way to show it #101

CreatSuns opened this issue Jan 24, 2019 · 5 comments

Comments

@CreatSuns
Copy link

My emulator runs normally. I change the code, but I cannot change it after saving. The log I get is as follows

💉 *** Compiling /Users/lishihang/Desktop/asd/asd/ViewController.m ***
💉 Loading .dylib - Ignore any duplicate class warning...
objc[4037]: Class ViewController is implemented in both /Users/lishihang/Library/Developer/CoreSimulator/Devices/E60C148D-0324-4667-A03B-9C8C13C9B0EE/data/Containers/Bundle/Application/36260E11-54A9-4BD1-ACE8-8018F23DE36B/asd.app/asd (0x1093e7ce8) and /Users/lishihang/Library/Containers/com.johnholdsworth.InjectionIII/Data/eval105.dylib (0x1271bd120). One of the two will be used. Which one is undefined.
💉 Loaded .dylib - Ignore any duplicate class warning...
@zenangst
Copy link
Collaborator

hey @CreatSuns, If you look closer at the message you'll see that this should be ignored :)

Messages that have the prefix 💉 belong to InjectionIII whereas Class ViewController is implemented… belong to the system and is nothing that we can opt-out from showing.

@CreatSuns
Copy link
Author

I can implement it but I have to declare the injected method. Is there any way I can inject it into real time without having to declare it?

@zenangst
Copy link
Collaborator

@CreatSuns you mean you need to add @objc func injected() {} into your classes for it to work?
This is actually by design so that InjectionIII knows which classes should be "sweeped" when injection happens.

What you could do is to add the method using an extension and then decide what the injected method should do for the class. Take a view controller for example, then you could do something like this:

extension UIViewController {
  @objc func injected() {
    viewDidLoad()
    viewWillAppear(true)
    viewDidAppear(true)
  }
}

This should trigger the view lifecycle every time a view controller is saved.
Hope I understood this correctly and that it was helped :)

@CreatSuns
Copy link
Author

Thanks for your advice

@jayhe
Copy link

jayhe commented Apr 30, 2019

add an @objc
injected() method or subscribe to the "INJECTION_BUNDLE_NOTIFICATION".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants