If your project is the use of code layout, in the code in the face of the layout of the control to make some adjustments, you can not see the effect of changes in real time, each change requires a rerun of the project. By using the Dyci tool, it can inject code when the program is running without restarting the project or seeing the effect of real-time modifications, which is helpful for debugging the UI. Here are some specific ways to use them.
1, install DYCI, only need to run a install.sh script on it. After the installation is successful, restart Xcode, and under the Product menu, an extra recompile and inject option is available.
git clone https://github.com/DyCI/dyci-main.git
CD dyci-main/install/
sudo sh install.sh
2, download the latest version of Dyci.framework, currently the latest version is v0.1.5.6.
3. Add the framework to your project and add the-OBJC tag to the other Linker flags setting because there is category in the Dyci library and you need to add this flag to make the category in the library effective.
4, if after adjusting the UI, want to see the effect immediately, also need to add Updateonclassinjection method in the code, after the code injected successfully, will callback this method, can in this method inside let the page rearrange, or reconstruct view.
UIView
-(void) updateonclassinjection {
[self setneedslayout];
[Self setneedsdisplay];
}
Uiviewcontrollers
-(void) Updateonclassinjection {
if ([self isviewloaded]) {
UIView * Viewsuperview = View.superview;
[Self.view Removefromsuperview];
Self.view = [self recreateview]; <--Custom Metod of view recreation
[Viewsuperview addsubview:[self view]];
}
5, adjust the page layout, and then save, and then press control+x shortcut keys, you will see the code injected the success of the log print out.