如何在 Xcode 中查看 PhoneGap 应用程序的 javascript 错误? [英] How to see the javascript errors of PhoneGap app in Xcode?

查看:30
本文介绍了如何在 Xcode 中查看 PhoneGap 应用程序的 javascript 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Xcode 中调试我的 PhoneGap 应用程序,但其控制台无法显示 javascript 错误.

I want to debug my PhoneGap app in Xcode, but its Console can not show javascript errors.

推荐答案

在 Cordova/PhoneGap 应用程序中查看和调试 JavaScript 错误的最优雅的方法是将 Web Inspector 从 Safari 浏览器附加到 iOS 中的 Web 视图应用程序(但是,就像汤姆克拉克森已经提到的那样,你至少需要 iOS 6).

The most elegant way to view and debug JavaScript errors in your Cordova/PhoneGap App is by attaching the Web Inspector from your Safari browser to the Web View in your iOS App (but, like Tom Clarkson already mentioned, you will need at least iOS 6).

  • 在您的 iPad 或 iPhone 上,使用设置"应用在 Safari 的高级设置"中启用 Web Inspector
  • 通过 USB 将您的设备连接到 Mac(然后它会出现在 Safari 的开发"菜单下)
  • 启动您的应用
  • 导航到要调试的 Web 视图
  • 在 Mac 上,从 Safari 开发菜单中,从其子菜单中选择您的设备和应用程序(其 HTML 页面)的名称
  • 将打开一个 Web Inspector 窗口,让您可以浏览 DOM、设置断点等.

有关设置的 Apple 文档

完整的第三方教程

或者,您可以在安装 iOS WebKit 调试代理后将 Chrome 的 Web Inspector 连接到 iOS 设备.这也开启了从 Linux 或 Windows 进行检查的能力.

Alternatively you could connect Chrome’s Web Inspector to iOS devices after installing iOS WebKit Debug Proxy. This also opens up the ability to do the inspection from Linux or Windows.

如今远程访问 iOS 的 HTML、CSS 和 JavaScript 变得更加灵活,因为您可以安装 RemoteDebug iOS WebKit Adapter 在上述调试代理之上.由于此适配器将WebKit 远程调试协议转换为Chrome 调试协议,这些(在其所有支持的平台上)可用作替代调试和检查工具:

Remote access to your iOS’s HTML, CSS and JavaScript has gotten even more flexible nowadays because you can install the RemoteDebug iOS WebKit Adapter on top of aforementioned Debug Proxy. Because this adapter translates the WebKit Remote Debugging Protocol to the Chrome Debugging Protocol, these (on all their supported platforms) become available as alternative debugging and inspection tools:

  • Visual Studio 代码
  • Chrome 开发者工具
  • Mozilla 调试器

顺便说一句,使用 Safari Web Inspector 进行远程调试甚至可以与 iOS 模拟器结合使用.

BTW, remote debugging with the Safari Web Inspector works even in combination with the iOS Simulator.

对于每个版本的 iOS,您都需要特定的最低版本的 Desktop Safari 才能使用远程网络检查,请参阅下面的列表.

For each version of iOS you will need a specific minimum version of Desktop Safari in order to use remote web inspection, see the list below.

这篇关于如何在 Xcode 中查看 PhoneGap 应用程序的 javascript 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆