1.以前cordova遠程調試,Android的直接連接USB后,用chrome打開chrome://inspect網址
(有人遇到第一次打開chrome inspect是空白頁面,是因為第一次要下載一些工具,是要翻牆的。當然有離線包可用,具體可以網上搜索。)
IOS的打開Safari的developer下。

這是因為cordova的webView都已經開放了遠程調試,
如果是自己的加的webView,要進行遠程調試
Android:
在調試WebView需要滿足安卓系統版本為Android 4.4+已上。並且需要再你的APP內配置相應的代碼,在WebView類中調用靜態方法setWebContentsDebuggingEnabled,如下:
if (Build.VERSION.SDK_INT >=Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); }
IOS:
利用WebView隱含的一個API
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // ...... [NSClassFromString(@"WebView") _enableRemoteInspector]; // ...... }
不過這是個私有API,ARC關閉的情況下才能這么寫,不然會報錯。
微信:
利用微信開發者工具進行遠程調試,具體操作很簡單
2.遠程調試可以debug那些web上看不出來,但是在在device上就出問題的情況
1.weex安裝完weex-toolkit
$ npm install -g weex-toolkit
就可以直接通過weex debug命令進行調試
2.比如下載的weex demo,進入根目錄,運行
weex debug examples
就會出現一些二維碼頁面,用playground app掃這個二維碼,瀏覽器里出現如下頁面

點擊remotedebug按鈕就可以進行遠程調試了
真機調試微信(android,ios)H5頁面:https://www.jianshu.com/p/c620ef778e1c
3.React Native
在運行帶RN的工程后,當前頁面下ios模擬器通過cmd+D(真機可以通過搖一搖),android通過Menu按鍵,調出RN的開發者菜單,
4.electron和node調試(vscode中)
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "program": "${workspaceFolder}/app/templates/electron/node-util/encrypt.js" //如果是debug當前文件,就是"${file}"
},
{ "name": "Debug Main Process", "type": "node", "request": "launch", "cwd": "${workspaceRoot}/app/templates/electron", "runtimeExecutable": "${workspaceRoot}/app/templates/electron/node_modules/.bin/electron", "windows": { "runtimeExecutable": "${workspaceRoot}/app/templates/electron/node_modules/.bin/electron.cmd" }, "args": [ "." ] },
]
}
vscode的launch.json里添加配置,然后就可以在vscode里打斷點調試node或者RN項目了
上面的第一個configure是調試node的,比如我的encrypt.js
第二個是調試npm 腳本
第三個調試webpack,並且加參數的
第四個是調試electron的,目錄那么長是因為是我自己的一個腳手架項目(https://github.com/johnzhu12/generator-rocky),electron的目錄比較深
各個配置的目錄各不相同,對應自己項目的目錄設置
最后deBugger jest
5.vscode調試karma
debugging Karma with Visual Studio Code
這里debug的斷點一定要打在sourcemap里,大在源碼里是不會被hit的
6. vscode 配置c/c++環境
clang編譯c,clang++編譯c++
launch.json和task.json
"configurations": [ { "name": "clang++ build and debug active file", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension}", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "preLaunchTask": "clang++ build active file" } ]
{ "tasks": [ { "type": "shell", "label": "clang++ build active file", "command": "/usr/bin/clang++", "args": [ "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}" ], "options": { "cwd": "/usr/bin" } } ], "version": "2.0.0" }
c_cpp_properties.json
{ "configurations": [ { "name": "Mac", "includePath": [ "/usr/local/include", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1", "${workspaceFolder}/**" ], "defines": [], "macFrameworkPath": [ "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks" ], "compilerPath": "/usr/bin/clang++", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "clang-x64" } ], "version": 4 }
上面配置都自己試過,親測有用
