Injection|Injection For Xcode11 macOS 10.15 Catalina 亲测可用iOS模拟器UI界面调试实时刷新工具

使用Xcode最痛苦的就是使用纯代码布局时界面的调试,这也是Xcode备受吐槽的一点.作为当代的前端IDE每次界面调试却需要重新完整的运行整App哪怕仅仅只是调整了一个字体大小也是如此.特别是在大中型项目与电脑配置比较差时,花5s时间调整一段代码,需要耗费5-20s来查看最终效果.这无疑是每个iOS开发者的噩梦,虽然在9102年苹果在千呼万唤中推出了SwiftUi,
官方示例 然'鹅'国外的一位朋友通过自己的(xia)努(zhe)力(teng),为大家提供了一款界面开发神器->GitHub Injection 可以像安卓与WEB一样,改颜色改字体改文字,改完command + s 片刻即刷新页面,是不是很shuang?
具体功能及详细使用请查看Injection官网 在 Mac AppStore 中也是可以搜索下载安装
xcode10用法:
Swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. #if DEBUG Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection10.bundle")?.load() //for tvOS: Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/tvOSInjection10.bundle")?.load() //Or for macOS: Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/macOSInjection10.bundle")?.load() #endifreturn true }

在需要修改的地方重写injected() (非必要)
@objc func injected() { //在这里改变背景颜色试试~~ command + s 即刻呈现 }

OC
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch.#if DEBUG //for iOS [[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/iOSInjection10.bundle"] load]; //for tvOS [[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/tvOSInjection10.bundle"] load]; //for masOS [[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/macOSInjection10.bundle"] load]; #endifreturn YES; }

在需要修改的地方重写- (void)injected{}
- (void)injected { NSLog(@"I've been injected: %@", self); self.view.backgroundColor = [UIColor blueColor]; for (UIView *value in self.view.subviews) { if ([value isKindOfClass:[UILabel class]]) { [value removeFromSuperview]; } } /*程序运行完成后打开下面代码的注释并保存即可在界面上看到改变 *///UILabel *lab = [UILabel new]; //lab.text = @"这是i一个新的label"; //lab.textColor = [UIColor whiteColor]; //lab.frame = CGRectMake(0, 0, 200, 20); //lab.center = self.view.center; //[self.view addSubview:lab]; }

支持Xcode 8.3.3安装包:Injection 支持Xcode 9.3安装包:Injection 支持Xcode 9.2安装包:Injection 支持xcode10安装包:Injection v1.2
//Xcode10需要将AppDelegate中的路径修改成 Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection10.bundle")?.load()

支持xcode11 AppStroe安装
//func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) #if DEBUG Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load() #endif

示例:TestDemo 【Injection|Injection For Xcode11 macOS 10.15 Catalina 亲测可用iOS模拟器UI界面调试实时刷新工具】1,运行Injection
2,运行演示项目将自动弹出一个文件夹选择界面选择项目文件夹并选中打开Injection 勾上File Watcher即可.
Tip: 感谢@君赏提供的项目零污染调试方法方法 Injection|Injection For Xcode11 macOS 10.15 Catalina 亲测可用iOS模拟器UI界面调试实时刷新工具
文章图片
项目零污染调试方法 实际测试保存代码后重新push即可更新Ui 由于语言特性该工具对于Swift支持并没有OC那么全面,但仅对于Ui界面调试来说已经足够. 最后提醒大家插件虽好,但使用需适量,也不要太过于依赖. end

    推荐阅读