iOS Development using Dyci Live debugging UI

Source: Internet
Author: User
Tags git clone

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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.