解決問題
iOS 開發 特別是OC 語言開發,每次都要run 對改動的部分進行觀察,已經落后 flutter / SwiftUI / 安卓等 UI 開發模式的效率問題.
這個InjectionIII 出了 好幾代了,我記得13年的時候就有了,在項目里面有的用 ,有的公司不用。
經歷了這么多年,還是挺好的,扛住了歷史的考驗,和語言一樣,時間是最好的老師
使用
官方原碼
這里說明一下,別看一堆issues 。都是歷史積累
1. appstore 下載 app
Mac 版本
2. 代碼里面嵌入
這里說明一下 ,一共兩種 嵌入模式
方法 一 在controller 里面 嵌入 這個代碼,每次保存代碼的時候 就會熱刷新
- (void)injected {
NSLog(@"injected Some thing....");
[self viewDidLoad];
}
方法 二 通過通知的方式
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)injectedAction {
// 這里調用需要執行的代碼
#ifdef DEBUG
[self viewDidLoad];
#endif
}
在viewdidload 里面
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(injectedAction) name:@"INJECTION_BUNDLE_NOTIFICATION" object:nil];
self.view.backgroundColor = UIColor.redColor;
[self layout];
// Do any additional setup after loading the view.
}
我的項目是OC 項目 ,所以 兩個方法我都試了,但是不知道為啥第一種 不起作用
3. open 自己項目文件 到 Inject
image.png
之后進行cmd + S就能看到效果....
注意
1 記得把debug加上
2 如果在基類里面 加 這個,記得加個開關 同組人員可能有的不用這個 不一定他寫UI
3 這個 配合Charles 的maplocal. 數據 Mock + UI 熱更新,基本你的效率Up+++++??????