“This is the first day of my participation in the First Challenge 2022. For details: First Challenge 2022.”
preface
Reveal (Revealapp.com) is an iOS application interface debugging tool. Reveal allows you to dynamically view and modify an application’s interface during iOS development.
In development, for dynamic or complex interactive interfaces, handwritten UI is unavoidable. Reveal makes it easy to debug and modify an application page without having to restart the application after each change.
Reveal introduction
Reveal’s “Review Elements” feature is similar to Chrome’s, which not only allows you to see the hierarchy of an iOS app’s interface at runtime, but also allows you to make changes to the app’s interface in real time, without having to re-run the app.
In use, we connected Reveal to the iOS program running on the simulator or real machine, and then we could view the interface for debugging the iOS program.
The following figure shows the Reveal operating interface, which is divided into three parts:
-
On the left is the hierarchy of the entire interface, where you can view all interface elements in a tree hierarchy.
-
In the middle part is the visual viewing area, where users can switch between 2D and 3D viewing mode, and where they can see the real-time interface of the program running.
-
The right part is the detailed parameter view area of the control, when we select a control, the right side can display the detailed parameter list of the control. In addition to viewing these parameter values, you can also modify them, and all changes are reflected in the middle preview area in real time.
Use of Reveal
Most of the methods officially introduced by Reveal require modification of the project files. Since there are many teams developing the project files at present, if the project files are modified, other members of the team also need to install Reveal, which is very unfriendly. The following describes how to debug the simulator and the real machine without modifying any project files.
2.1 Create an. Lldbinit file and edit it
Open the terminal, enter vi ~/. Lldbinit to create an. Lldbinit file, enter the following content in the file, and run the :wq command to save the configuration and exit.
command alias reveal_load_sim expr (void *)dlopen(“/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib”, 0x2); \
command alias reveal_load_dev expr (void *)dlopen([(NSString *)[(NSBundle *)[NSBundle mainBundle] pathForResource:@”libReveal” ofType:@”dylib”] cStringUsingEncoding:0x4], 0x2); \
command alias reveal_start expr (void)[(NSNotificationCenter *)[NSNotificationCenter defaultCenter] postNotificationName:@”IBARevealRequestStart” object:nil]; \
command alias reveal_stop expr (void)[(NSNotificationCenter *)[NSNotificationCenter defaultCenter] postNotificationName:@”IBARevealRequestStop” object:nil]; \
In this step, four names are set for the LLDB to facilitate subsequent operations. The meanings of the four names are as follows:
Reveal_load_sim loads a dynamic link library for reveal debugging for the simulator.
Reveal_load_dev loads a dynamic link library for reveal debugging for the real machine.
Reveal_start Starts the Reveal debugging function.
Reveal_stop stops the reveal debugging function.
Note: Aliases such as Reveal_load_sim can be set to your preference.
2.2 Simulator Debugging
The application of the AppDelegate class: didFinishLaunchingWithOptions: method, for the following three steps:
Add a Breakpoint on the first line inside the method and Edit the Breakpoint “Edit Breakpoint”;
Click the “Add Action” button to the right of “Action” and enter the alias of the simulator loading dynamic library: “Reveal_load_sim”;
Select Automatically continue after evaluating Actions on Option
Then run the iOS application and open Reveal. In the upper left corner of the Reveal interface, see whether there is an emulator that can be connected to debug. If so, view and debug the iOS application.