美文网首页
iOS原生开发热重载

iOS原生开发热重载

作者: liboxiang | 来源:发表于2021-03-19 16:16 被阅读0次

github: https://github.com/johnno1962/InjectionIII
别人的介绍文章:https://www.jianshu.com/p/0489c654657d

使用步骤:

  • App Store安装 InjectionIII
  • 打开InjectionIII(屏幕右上角有个针筒💉图标),Open Project->选中你要打开的项目
  • 打开iOS项目,在AppDelegate.m文件中applicationDidFinishLaunching:方法内添加
#if DEBUG
[[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle"] load];
#endif
  • iOS项目Build Settings的Other Linker Flags在debug下添加-Xlinker -interposable
  • 模拟器运行iOS工程,如果一切顺利,就会发现屏幕右上角的针筒变成橙色了,如果报Can't find ordinal for imported symbol for architecture x86_64错误,则在Build Settings的Other Linker Flags的debug中在添加-Xlinker -undefined -Xlinker dynamic_lookup

有些方法不能动态调用刷新页面的,可以通过添加- (void)injected方法进行动态调用

- (void)injected{
//保存代码后会跑到执行此处代码
    [self refresh];
}

相关文章

网友评论

      本文标题:iOS原生开发热重载

      本文链接:https://www.haomeiwen.com/subject/rwjvcltx.html