打开 webkit 远程调试启动移动浏览器

发布于 2024-11-25 17:50:59 字数 1024 浏览 4 评论 0 原文

Paul Irish 和 Pavel Feldman 在 Google I/O 2011:Chrome 开发工具重装上阵引入了新的远程调试功能 - 这是在传递包含在 webkit 中。

——

这是个好消息,特别是对于移动网络开发人员来说。 但是我们如何启用它,例如启动 IOS 模拟器,或者只是在 iPhone 上运行 Safari Mobile? (对于 chrome,这通常是在启动时使用 --remote-debugging-port=9222 选项完成的)。

我尝试在 safari 设置中启用开发人员模式(Settings > Safari > 开发人员 > 调试控制台:ON)但没有成功......

我不知道安卓在这里,但是有谁知道Apple(Safari Mobile)或Google(android的浏览器)何时会包含此新功能,以便我们可以在移动开发中享受远程调试?

谢谢。

参考:http://paulirish。 com/2011/a-re-introduction-to-the-chrome-developer-tools/#comment-63113

At Google I/O 2011: Chrome Dev Tools Reloaded, Paul Irish and Pavel Feldman introduced new remote debugging feature — which was in passing included into webkit.

--

This is great news, particularly for mobile web-developers.
But how do we enable it, for example launching IOS simulator, or just running Safari Mobile on an iPhone? (for chrome this is traditionally done with --remote-debugging-port=9222 option while launching it).

I tried enabling developer mode in safari settings (Settings > Safari > Developer > Debug Console: ON) but without success...

I don't know about android here, but does anyone know when Apple (Safari Mobile) or Google (android's browser) will include this new feature so we can enjoy remote-debugging in mobile development?

Thank you.

Ref: http://paulirish.com/2011/a-re-introduction-to-the-chrome-developer-tools/#comment-63113

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

北陌 2024-12-02 17:50:59

iOS 6 上的 Safari
在 iOS6 中,您现在可以从 Safari 6(仅限 OS X)进行远程调试。在设备上,打开“设置”>“野生动物园>高级>启用 Web 检查器。打开 Safari 首选项、高级,选中“在菜单栏中显示开发菜单”。使用 USB 数据线连接您的 iPhone/iPad。现在,在“开发”菜单栏下,您应该会看到一个适合您设备的子菜单,其中包含您在设备上的 Safari 中打开的选项卡。

iOS 7 上的 Safari
除了上述要求外,您还需要 Safari 6.1,目前(2013 年 10 月 8 日)仅作为开发人员的种子提供:https://developer.apple.com/downloads/index.action?name=Safari%206.1

Android 上的 Chrome 4
Android 上的情况稍微复杂一些。有关 Android 版 Chrome 远程调试的说明,请访问:https://developers.google.com/ chrome/mobile/docs/debugging
我还没有找到在Android默认浏览器(v4.04)中启用远程调试的方法。

Safari on iOS 6
In iOS6 you can now remote debug from Safari 6 (only OS X). On the device, open Settings > Safari > Advanced > Enable Web Inspector. Open Safari Preferences, Advanced, check "Show Develop menu in menu bar". Connect your iPhone/iPad with a USB cable. Now under the Develop menu bar you should get a submenu for you device with the tabs you have open in Safari on your device.

Safari on iOS 7
In addition to requirements above you will need Safari 6.1, which at the moment (Oct. 8th 2013) is only available as a seed for developers: https://developer.apple.com/downloads/index.action?name=Safari%206.1

Chrome on Android 4
It's a bit more complicated on Android. Instructions for remote debugging on Chrome for Android here: https://developers.google.com/chrome/mobile/docs/debugging
I haven't found a way to enable remote debugging in the Android default browser (v4.04).

等待圉鍢 2024-12-02 17:50:59

看一下这个 bash 脚本,用 iOS 模拟器启动远程检查器: https://gist.github.com/2241976

Take a look at this bash script to start the remote inspector with iOS simulator: https://gist.github.com/2241976

满栀 2024-12-02 17:50:59

现在Android 版 Chrome 支持此功能。

It's now supported in Chrome for Android.

月朦胧 2024-12-02 17:50:59

目前还没有移动浏览器实现 webkit 远程调试协议。 (也许您可以获得支持它的 Android 自定义版本)

但是 weinre 为您提供了 Web 检查器的远程版本。但是您必须在页面中包含一些代码才能支持它。 (因为它不是浏览器功能)。

Weinre 网站

Weinre github 存储库

Currently no mobile browser is implementing the webkit remote debugging protocol. (Maybe you can get custom builds for android that support it)

However there is weinre, which is giving you a remote version of the web-inspector. But you have to include some code in your page in order to support it. (Because it's not a browser feature).

Weinre website

Weinre github repo

凤舞天涯 2024-12-02 17:50:59

内森·德弗里斯< /a> 弄清楚了如何在模拟器中运行的 iOS5 上执行此操作。它围绕调用私有 _enableRemoteInspector 方法。

阅读它。摘要如下:

要为 Mobile Safari 启用此功能,请使用 gdb 附加到它并调用方法:

MobileSafari_PID=$(ps x | grep "MobileSafari" | grep -v grep | awk '{ print $1 }')

if [ "$MobileSafari_PID" == "" ]; then
  echo "Mobile Safari.app must be running in the Simulator to enable the remote inspector."
else

  cat <<EOM | gdb -quiet > /dev/null
  attach $MobileSafari_PID
  p (void *)[WebView _enableRemoteInspector]
  detach
EOM

fi

然后通过 http://localhost:9999/ 访问检查器。

使用嵌入式 UIWebView,像这样启用它:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // ...Snipped...
  [NSClassFromString(@"WebView") _enableRemoteInspector];
  // ...Snipped...
}

在真实设备上它不起作用,可能是因为端口受防火墙保护 - 如果您有越狱设备,您可能会绕过这个问题(如果您做)。

Nathan de Vries figured out how to do this on iOS5 running in the simulator. It revolves around calling the private _enableRemoteInspector method.

Read it. Summary follows:

To enable this for Mobile Safari, attach to it with gdb and call the method:

MobileSafari_PID=$(ps x | grep "MobileSafari" | grep -v grep | awk '{ print $1 }')

if [ "$MobileSafari_PID" == "" ]; then
  echo "Mobile Safari.app must be running in the Simulator to enable the remote inspector."
else

  cat <<EOM | gdb -quiet > /dev/null
  attach $MobileSafari_PID
  p (void *)[WebView _enableRemoteInspector]
  detach
EOM

fi

Then access the inspector at http://localhost:9999/.

With an embedded UIWebView, enable it like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // ...Snipped...
  [NSClassFromString(@"WebView") _enableRemoteInspector];
  // ...Snipped...
}

On a real device it doesn't work, probably because the port is firewalled - if you have a jailbroken device you may get around that (update us if you do).

未央 2024-12-02 17:50:59

仅仅因为某个功能在 WebKit 的一个端口(在本例中为 Apple 和 Chromium)中实现,并不意味着它在其他地方始终可用。我在关于 不同的 WebKit 端口实现

到目前为止,唯一具有远程调试功能的移动WebKit端口是RIM Playbook浏览器。

对于 iOS 来说,很难知道,因为苹果从来没有提供任何有关其未来产品的信息。至少我们知道 iOS 5 不会有它,因为测试版没有显示任何相关内容。

对于 Android,它肯定会在未来的版本中出现,因为 Android 人员 采用 Chromium 作为其 WebKit 的新基础。

Just because a feature is implemented in one port of WebKit (in this case, Apple and Chromium), does not mean it is always available elsewhere. I wrote this in details in my blog post about different WebKit ports implementation.

So far, the only mobile WebKit port which has the remote debugging feature is RIM Playbook browser.

For iOS, it is very difficult to know because Apple does not give any information about its future product ever. At least we know that iOS 5 will not have it since the beta versions do not show anything related.

For Android, definitely it is coming in a future release, since Android folks are adopting Chromium as the new basis for its WebKit.

樱花落人离去 2024-12-02 17:50:59

Adobe 的 Shadow 实用程序(刚刚发布)允许您使用 weinre 无需向您的网页注入任何代码。它与 Windows 和 Mac 上的 Chrome 配合使用,作为“主”浏览器,并将每个页面导航同步到运行 iOS 或 Android 客户端的任意数量的设备。

请注意,weinre 本身是有一定限制的。例如,您将无权访问“网络”选项卡。

Adobe's Shadow utility (which was just released) allows you to debug remotely using weinre without needing to inject any code into your web pages. It works with Chrome on Windows and Mac as the "master" browser and will sync every page navigation over to any number of devices running the iOS or Android client.

Note that weinre itself is somewhat limited. For example you won't have access to the Network tab.

无人问我粥可暖 2024-12-02 17:50:59

Thomas 指出了远程调试的绝佳资源,但他指出您需要将代码添加到网页中。这并不完全正确,因为 weinre 还允许通过小书签进行交互。页面下方这里(在方便地称为“使用书签”),它说它应该适用于 Android 2.2+ 和 iOS。

需要注意的一些相关事项:

  1. 它不允许您调试启动错误(必须加载页面才能打开小书签)。
  2. 如果您失去连接,它似乎不会重新连接(您必须刷新页面才能再次获得连接)。
  3. 如果你的 js 已经坏了,它也已经坏了。

也可以(我自己做过)使用 webview 从 android 浏览器“调试”代码。您可以让 webview 捕获所有方法调用(即 console.log)。使用它您可以捕获并保存消息,或将消息转发到 logcat。

与您已经尝试过的方法相关 - 当您在 iOS 上启用调试控制台时,您在哪里寻找交互/日志输出?更具体地说,您是否检查了 xCode/iPhone 模拟器中的调试控制台?

Thomas points out an excellent resource for remote debugging, however he states that you need to add the code to the webpage. This is not strictly true, as weinre also allows interaction through bookmarklets. Part way down the page here (under the section conveniently called "Using a bookmarklet"), it says it should work for Android 2.2+ and iOS.

Some relevant things to note:

  1. It will not allow you to debug start errors (page already has to be loaded to open the bookmarklet).
  2. It doesn't seem to reconnect if you lose connection (you have to refresh the page to get the connection again).
  3. If your js is broken already, it will already be broken as well.

It is also possible (I have done it myself) to 'debug' code from the android browser using a webview. You can have the webview catch all method calls (ie. console.log). Using that you can catch and save, or forward the messages to logcat.

Related to the method you have already tried - when you enabled the Debug console on iOS, where were you looking for interaction/logging output? More particularly, did you check in the debugging console in xCode/iPhone simulator?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文