作用
InjectionIII可以让你更改的UI效果实时的在模拟器上显示,无需重新启动应用程序,从而节省开发人员的时间
使用方法
- 在 App Store 下载安装 InjectionIII
- 添加相应的代码
Xcode10之前:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#if DEBUG
// iOS
[[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle"] load];
// tvOS
[[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/tvOSInjection.bundle"] load];
// macOS
[[NSBundle bundleWithPath:@"//Applications/InjectionIII.app/Contents/Resources/macOSInjection.bundle"] load];
#endif
// Override point for customization after application launch.
return YES;
}
Xcode10之后:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#if DEBUG
// iOS
[[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/iOSInjection10.bundle"] load];
// tvOS
[[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/tvOSInjection10.bundle"] load];
// macOS
[[NSBundle bundleWithPath:@"//Applications/InjectionIII.app/Contents/Resources/macOSInjection10.bundle"] load];
#endif
// Override point for customization after application launch.
return YES;
}
-
选择项目文件夹
4.在实时显示的类中添加 代码
- (void)injected
{
NSLog(@"I've been injected: %@", self);
}
5.更改后com+s 保存 模拟器会实时更新效果