The use of UI debugging artifact Reveal

 The use and cracking of Reveal

Town floor plan

The most important part of mobile development is undoubtedly UI and interaction, and UI debugging is also a hard thing that mobile developers often do. Although the current iOS development tool Xcode integrates the UI debugging function (Debug View Hierarchy), it brings us only disappointment. Next, as you can see in the title, the author will briefly introduce and use Reveal, because it is not difficult to use, so I will focus on how to integrate it into the project. But... this tool is charged, but fortunately we are in China (you know, brute force).

basic introduction

The use of Reveal is actually very simple, just like the effect of the first town floor plan. The middle is the 3D visualization view of the current APP page, the left side is the UI elements and hierarchy, and the right side is the View properties, you can modify the View's color, frame, etc., and the effect is still rendered to the simulator in time of. You can understand it at a glance when you actually use it. As for the download of Reveal, just go to Google and get it. As for the children's shoes that have not climbed the wall, you can simply Baidu.

integrated

There are two ways to integrate Reveal into a project. The first is to add Reveal frameworkto the project (not recommended). The second is to use the LLDB command (recommended for vomiting blood).

framework integration (not recommended)

For the frameworkintegration method, please refer to an article I wrote on CSDN a long time ago, click me to send it . Because the disadvantage of integrating in this way is that you have to configure the project, other linker Flagsand be careful not to package it together when it is packaged and released. And each project has to join the Reveal framework and configure it other linker Flags. So the question is, is there a way to do it once and for all? Is it to configure the environment once and use it directly no matter how many projects there are in the future? The answer is yes. That is to use the second way to configure LLDB, because this requires a little basic knowledge of LLDB, which will be briefly introduced in this chapter.

LLDB integration (recommended for vomiting blood)

LLDB集成的优势就是在于不用担心打包会把Reveal的framework也打包进去的问题。而且本地配置好了,只要在这台机器上任何项目都通用。最最最主要的一点就是,高bigger。

使用LLDB命令集成其实也很简单,大体分为如下两步。

第一步: 点击pause program execution,暂停app。(如下图)

暂停app的效果图

第二步: 依次输入两条命令即可,分别如下:

第一条:

ps:/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib这个地址为绝对路径,我的Reveal是存放于application目录下的,所以路径就是/Applications/Reveal.app/.....

第二条

两条命令顺利的话,控制台则会打印INFO: Reveal Server started (Protocol Version 25).这条信息。(如下图)

成功之后的效果图

ps:如果最后未能正常输出INFO: Reveal Server started,那你就要好好检查一下第一条命令里的dlopen里包含的路径是否正确了。

最后,你在点击continue按钮或者在控制台里继续输入c字符然后回车,让程序结束暂停即可。

现在,你在打开你的Reveal,在你的左上角点击No Connection,瞅瞅,是否有你的app啦。接下来你就好好的享受Reveal带给你的快感吧。。。

.lldbinit里设置别名

但是,这还没有结束尼。每次需要Reveal来审查UI的时候都要输入这两条看着如此蛋疼的命令。这,不是要我老命嘛? so... 幸运的是我们可以在~/目录下的.lldbinit文件里为我们的LLDB命令添加别名。

首先,简单科普一下吧。.lldbinit是一个隐藏文件,貌似默认是没有的。而Xcode每次启动的时候,则都会去~/.lldbinit这个目录寻找这个文件里的LLDB命令。所以我们可以在这个文件里进行一些命令的初始化设置或者设置别名等等(本篇不做这方面介绍)。

现在,我们打开终端,在终端里输入touch ~/.lldbinit命令来进行创建。然后在输入open ~/.lldbinit命令。则就会以文本编辑器打开此文件。然后再把如下字符复制到文本编辑器里即可:

command alias 其格式为:command alias 别名 LLDB命令,因此如上zxp_reveal_startzxp_reveal_load_sim就是我设置的别名。你们也可以替换成你们自己喜欢的名字

然后,现在在按照如上LLDB集成的步骤,运行项目,暂停app,这时候你在输入zxp_reveal_load_sim然后在输入zxp_reveal_start即可在Reveal里审查你的UI元素了。(如下图)

自定义LLDB命令使用的效果图

破解

由于Reveal是收费的,所以我们得要用点手段才行。正所谓上有政策下有对策嘛。其实也很简单,直接把~/Library/Preferences/com.ittybittyapps.Reveal.plist这个路径下的这个文件给干掉,然后在重启一下电脑即可。但这并不是完全破解,而是一直循环30天试用。等30天试用完了,在把这个文件干掉,然后在重启电脑即可。当然~/Library/Preferences/这个目录下的文件较多,现在你打开你的终端,然后输入rm ~/Library/Preferences/com.ittybittyapps.Reveal.plist这条命令即可删除。然后继续重启你的电脑吧。这个破解方法简单粗暴也实用,如果童鞋们有其他更好的方法或者有完全破解不需要循环30天的方法,还望多指点我。

更新20170112

以上破解需要重启电脑,现在有种方式可以不用重启电脑即可。打开终端输入defaults delete com.ittybittyapps.Reveal命令即可。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325237323&siteId=291194637