Mobile front-end development of real-computer debugging strategy

Source: Internet
Author: User

Mobile front-end development of real-computer debugging strategy

IOS mobile app (Safari developer tools)

Mobile: Set →safari→ advanced →web checker → on.

Mac side: safari→ preferences → advanced → display the "Development" menu in the menu bar.

After you start safari in OS X, connect to your IOS device with a USB cable and launch safari on this mobile device. By clicking "Develop" on the Safari menu on your computer, you can see the name of your IOS device, which is a submenu of all of Safari's tabs on your mobile device, and click on any one to start debugging.

Convenient, simple, can also debug shell wrapped browser such as.

Note: By the way, to debug different versions of iOS, you can go to Xcode to download different system packages (of course, without the device, local tyrants Skip)

Second, Android mobile terminal

1. Chrome Debugging method

First make sure that you have the latest version of Chrome on your phone and PC, followed by opening the phone's developer options and allowing debugging, and then connecting the data cable to two devices. Open chorme on the PC, enter Chrome://inspect, and then open chrome on your phone, and the phone will pop-up to ask if debugging is allowed, of course. Sometimes the phone lock screen will be disconnected, please unplug the USB again.

Click Inspect Open Devtools, you can select the DOM element in the page, while the corresponding element in the device is also highlighted, you can also use the inspect element in Devtools to select the target element, you can interact with the mobile device page in real-time, easy to locate the problem, With code debugging, you can play as happily as the PC side. If there is a problem, please check the chrome version.

Chrome's debugs are generally only available for debugging Chrome pages, but its official documentation says it can also debug webviews:

"On your computer, the Chrome://inspect page displays every connected device, along with its open tabs and debug-enabled W Ebviews. "

Need to explain that debug WebView need to meet Android 4.4+ version, and need to configure the corresponding code within your app, call the static method setwebcontentsdebuggingenabled in the WebView class, as follows:

if (Build.VERSION.SDK_INT >=Build.VERSION_CODES.KITKAT) {     WebView.setWebContentsDebuggingEnabled(true);  }

The above configuration method is suitable for all webview situations in Android applications.

Whether the Android WebView can be debugged does not depend on the manifest flag variable debuggable in the app, if you want to allow WebView remote debugging only when Debuggable is true, use the following code snippet:

if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.KITKAT) {     if (0 != (getApplicationInfo().flags &=ApplicationInfo.FLAG_DEBUGGABLE{        WebView.setWebContentsDebuggingEnabled(true); } }

I've only written about it here, if you have any other questions or want to see the detailed documentation, see the link below (bring your own ladder):

Https://developer.chrome.com/devtools/docs/remote-debugging

Note: The same you can also be installed on the computer Android virtual machine, recommended Genymotion, the same, want to test what version, on their own ROM, of course local tyrants when I did not say.

2. UC Developer Browser

Because the mobile end is not recommended to use UC (everyone should consciously resist mobile cancer), so I just briefly say, if you are interested, please check: http://www.uc.cn/business/developer/

It doesn't have the same debugging options as Chrome.

3. Debug with Weinre

This method is an old one, and it is a slash-and-burn type for other debugging methods. Weinre is a debug package that itself provides a javascript that requires you to include the JS in the project file. First install the weinre, we use the Nodejs installation, using the-G global command, so that can be accessed in various directories:

NPM install-g weinre

After installing Weinre, set the IP for listening to this machine:

Then open the description document of the returned address, then write the returned JS to the debug document and note where I pointed the arrows.

In this way, when the page is loaded, this JS will be controlled by Weinre.

Tip: This JS behind the #anonymous play a role in the logo, in order to differentiate, we can change it into a #test on the page. At this time, the address of our Inspect panel is not http://172.16.0.2:8080/client/#anonymous, but http://172.16.0.2:8080/client/#test.

When we visit the page, it will appear in the listener list, if there are multiple pages, you can select one from the list. You can then use the rear Elements, Console and other panels to debug the operation:


Weinre is very flexible, just need to load this JS in the page, and then access, so WebView can use this method to debug, some low version of Android, IOS can also support, Window Phone is also available. When debugging a mobile device, you may need to build a local LAN IP server, connect the device to the native network as a LAN, and use the mobile device to access the Web page.

Of course weinre is not omnipotent, compared to the Chrome debugging tools, it lacks JavaScript debug and Profiles and other common features, but it is strong compatibility, can implement the basic debugging functions.

4. Mihtool Test

Mihtool is developed by the Chinese, based on the weinre, used for IOS device front-end development testing.

The same way as Weinre debugging, that is, to open a server, and then insert JS into the page, access to debug.

Mihtool This process simplified, it is an APP that can be installed directly into your IOS device, and then built a simple browser can open your test page, when it is turned on, will automatically insert weinre JS to the page, and inform Weinre console URL and other information, so that you can be accessed for debugging.

It also provides a common weinre debugging service that generates links like http://i.mihtool.com/dev/client/#AwAj, which can be debugged with open debugging, which is a few cards.

5, mobile device online testing

So many mobile devices, small companies or teams, don't have so much money and energy to buy so many test equipment to test. So someone buys these devices, connects them, and provides online debugging services.

Usually his real phone device is turned on and then snapped out for preview.

For example: https://www.browserstack.com, of course, the general comparison card.

(say this seems to be able to brush a little PV and UV out ...) )

Iii. Summary

Many debugging methods, endless, the key is to see whether they are comfortable and skilled, the key lies in the amount of time to complete the development of the task.

The key lies in the usual accumulation of multi-pit posture, less write a little incompatible code, debugging on a comfortable point.

If this is not enough, you can view more information:
Mobile front-end development debugging: http://yujiangshui.com/multidevice-frontend-debug/
Mobile development Real-machine debugging: http://www.cnblogs.com/constantince/p/4711098.html
Remote_inspect_web_on_real_device:https://github.com/jieyou/remote_inspect_web_on_real_device
Remote-debugging:https://developer.chrome.com/devtools/docs/remote-debugging
Chrome remote Debugging for mobile Web development debug (remote Debugging): http://blog.csdn.net/freshlover/article/details/42528643

An Chengjian

2015/11/3 at hundred word slash

--------------Supplemental Part---------------

A lot of friends say why not write Browser-sync, and give a bad comment, to tell the truth, I didn't know that thing before. Took a moment to look and found their official website: http://www.browsersync.io/thought it was kinda fun, huh.

And then use, feel OK, really will save a lot of work, the introduction is fast, almost 5 minutes quick start, the front wheel is like this ...

1, first install Browsersync

install -g browser-sync

2, start Browsersync, the principle should be the kind of detection file changes, and then in the server WebSocket notify the browser changes, and then load a new change file, in the browser does not support WebSocket on the rotation service side changes, loading new files. I just grabbed the bag and looked at it, and I didn't know that I was right. 233

At this point there are two situations, one of which is static:
Listening to CSS files

browser-sync start --server --files "css/*.css"

Listen to CSS and HTML files

browser-sync start --server --files "css/*.css, *.html"

Two kinds are dynamic:
Host name can be IP or domain name

browser-sync start --proxy "主机名" "css/*.css"

And then it's easy to get started.

There are gulp to cooperate with OH. Just read the document: Http://www.browsersync.io/docs/gulp

Browsersync itself integrates a number of tools, such as practical Wiener, as well as the layout of the shadow and other tools, it is indeed convenient a lot. Now so many tools, I recommend Browsersync, really good.

Mobile front-end development of real-computer debugging strategy

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.