InjectIII-Xcode高效神器
iOS 日常开发中,经常需要微调界面,每次微调都需要重新编译,效率低下。
InjectionIII 是一款 Xcode 插件,支持热重载,也就是说不需要重新运行,即可看到修改效果,大大提高开发效率。
效果如下:

如何使用 InjectionIII?
在 Mac Appstore 安装 InjectionIII,启动 InjectionIII
[基于 XCode10 ] 在目标工程 didFinishLaunchingWithOptions 方法中添加如下代码:
OC:
1
2
3#if DEBUG
[[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/iOSInjection10.bundle"] load];
#endifswift:
1
2
3#if DEBUG
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection10.bundle")?.load()
#endif在顶部点击 InjectionIII 选择 openproject,选择目标工程目录。
在需要修改的 viewcontroller 中新增 injected 方法:
OC:
1
2
3- (void)injected{
_lable.text = @"xxx"; //微调界面的代码
}swift:
1
2
3
4
5func injected() {
widthLayoutC.constant = 600
heitghLayoutC.constant = widthLayoutC.constant
imageView.image = UIImage.init(named: "1.png")
}运行目标工程
修改 injected 方法中的代码,ctrl + s 保存,保存后即可看到修改后的效果。
方法说明
- (void)injected
or@objc func injected
修改实例中的变量和属性。- 其他模块可以通过监听
“INJECTION_BUNDLE_NOTIFICATION
” 来联动.