Weex devtools is a custom devtools for weex that implements Chrome Debugging Protocol inspired by Stetho, it is designed to help you quickly inspect your app and debug your JS bundle source in a Chrome web page. To make it work, at first you must integrate devtool to your App. This page will help you integrate devtool to your iOS App.
There are two choices to install dependencies:
I strongly recommend you use the latest version since both Weex SDK and devtools are developed iteratively and rapidly.
Get source code by GitHub.
Copy source folder to your project.
Choose options as the picture shows.
From cocoapods:#import <TBWXDevtool/WXDevtool.h>``- From source code
#import “WXDevtool.h”#### Step 2. Initialize inspector when the APP launchedYou can see the WXDevtool header file as follows:```object-c#import <Foundation/Foundation.h>@interface WXDevTool : NSObject/*** set debug status* @param isDebug : YES:open debug model and inspect model;* default is NO,if isDebug is NO, open inspect only;* */+ (void)setDebug:(BOOL)isDebug;/*** get debug status* */+ (BOOL)isDebug;/*** launch weex debug* @param url : ws://ip:port/debugProxy/native, ip and port is your devtool server address* eg:@"ws://184.108.40.206:8088/debugProxy/native"* */+ (void)launchDevToolDebugWithUrl:(NSString *)url;@end
Note: The inspector API must be called before weex is initialized
setDebugis used to control the state of debug mode, when its value is
YES, open the debug mode, otherwise closed.
wssip was the wss address showing in the chrome address bar.
open debug model and inspector model
open inspect model, remove the
(setDebug:) or add
Q: Why do we need auto refresh feature?
Q: What kind of scene need to add refresh feature?
- Click debugger button
- Switch remoteDebug
- Refresh inspect page
Q: How to add auto refresh feature?
Register events when Weex initialization.
Notes: You must cancel this event in the
dealloc method. For example:
For example, First you can destroy the current instance, and then re-create instance:
页面刷新实现，先销毁当前 instance，然后重新创建 instance，举例如下:
You can see the details in this case WXDemoViewController.m