background
As we all know, on the iOS platform, in order to Debug the javascript code running in the WKWebView or JavaScriptCore App, it is generally required to deploy the App project with the Debug configuration on the mobile phone using Xcode. Then use the corresponding option in Safari Developer menu on PC to debug.
The problem
The internal test package and online package of the company are generally packaged with Disrubution or enterprise certificate, and these two packages are often used for on-site troubleshooting. Safari debugging of this package is not supported.
plan
App
In theThe Debugger module
At run timeWKWebView
orJavaScriptCore
Object address by usingWebKit
internalC++ API
Access its debug message-related interface- The input and output of the message interface support
WebKit debugging protocol
data
- The input and output of the message interface support
App
In aWebSocket
The server that forwards external requests toThe Debugger module
When forwarding, you also need to pass in the externalChrome Debugging Protocol
Data conversion toWebKit debugging protocol
dataChrome
toWebKit
Protocol conversion referenceOpen source implementation of node.js version
PC
withChrome
Open the following address (fill in the correct oneWebSocket
The server’sIP
Address and port number), connectionStep 2
In the server, you can achieve real machine debugging.chrome-devtools://devtools/bundled/inspector.html? Ws =[IP address]:[port number] Copy the code