作用
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:@"http://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:@"http://Applications/InjectionIII.app/Contents/Resources/macOSInjection10.bundle"] load];
#endif
// Override point for customization after application launch.
return YES;
}
-
選擇項目文件夾
image.png
4.在實時顯示的類中添加 代碼
- (void)injected
{
NSLog(@"I've been injected: %@", self);
}
5.更改后com+s 保存 模擬器會實時更新效果
效果展示
2019-03-25 10-48-14.2019-03-25 10_56_30.gif