刚开始没重写 - (void)injected { } , 发现修改一直没反应, 控制台还收到了相应警告
💉 Injection connected, watching /Users/user/JerseyCafe/JerseyCafe/MySampleCode/JSDPlayground/**
💉 *** Compiling /Users/user/JerseyCafe/JerseyCafe/MySampleCode/JSDPlayground/JSDPlayground/Class/Launch/JSDHomeVC.m ***
💉 Loading .dylib ...
objc[22080]: Class JSDHomeVC is implemented in both /Users/user/Library/Developer/CoreSimulator/Devices/042DBB6D-8059-43E7-A609-3034F6D949AD/data/Containers/Bundle/Application/4BCF4C6E-3650-484C-BAE8-7ACB3B3A3E6E/JSDPlayground.app/JSDPlayground (0x10695a278) and /Users/user/Library/Containers/com.johnholdsworth.InjectionIII/Data/eval101.dylib (0x12cf821d8). One of the two will be used. Which one is undefined.
💉 Loaded .dylib - Ignore any duplicate class warning ^
然后找了下 github Issue [Issue](https://github.com/johnno1962/InjectionIII/issues/101) 原来要在相应的文件下重写 injected 方法, 在 .m 下添加下列代码即可
Swift:
extension UIViewController {
@objc func injected() {
viewDidLoad()
viewWillAppear(true)
viewDidAppear(true)
}
}
OC:
- (void)injected {
[self viewDidLoad];
[self viewWillAppear:YES];
[self viewWillDisappear:YES];
}
直接修改代码即可, command + s 自动刷新。
不过还是收到相应警告。
展开