xcode iOS PhoneGap 调试工作流程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11207001/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:41:27  来源:igfitidea点击:

iOS PhoneGap debug Workflow

javascriptiosxcodecordova

提问by Chris G.

How do you debug javascript in Xcode?

你如何在 Xcode 中调试 javascript?

One thing that I can do is open the page in OS X Chrome browser, but naturally this will not work for application flow involving native code. Is there a smart Xcode trick that I am missing.

我可以做的一件事是在 OS X Chrome 浏览器中打开页面,但这自然不适用于涉及本机代码的应用程序流。是否有我缺少的智能 Xcode 技巧。

回答by Ben Roberts

With the release of iOS 6, Apple released remote Web Inspector for their Mobile Safari in conjunction with Mac Safari 6, and this is huge. Basically you have all the features and power of Web Inspector in regular Safari, for your mobile apps, including Phonegap apps. I've used weinre and this makes it obsolete for newer versions of iOS (but not for old versions of iOS, non-iOS devices such as android, or if you're on Windows).

随着 iOS 6 的发布,Apple 为他们的 Mobile Safari 与 Mac Safari 6 一起发布了远程 Web Inspector,这是巨大的。基本上,您拥有常规 Safari 中 Web Inspector 的所有功能和强大功能,适用于您的移动应用程序,包括 Phonegap 应用程序。我使用过 weinre,这使得它对于较新版本的 iOS 已经过时了(但不适用于旧版本的 iOS、非 iOS 设备,例如 android,或者如果您使用的是 Windows)。

Here's how it works (requires a Mac, either xCode 4.5+ running an iOS 6+ simulator or an iOS 6+ device, and Safari 6+ on your Mac):

这是它的工作原理(需要 Mac,运行 iOS 6+ 模拟器的 xCode 4.5+ 或 iOS 6+ 设备,以及 Mac 上的 Safari 6+):

in your ios simulator or ios device,open settings --> Safari --> Advanced --> Web Inspector --> (turn On) . (this is on by default in the simulator, but its worth checking)

在您的 ios 模拟器或 ios 设备中,打开设置 --> Safari --> 高级 --> Web Inspector -->(打开)。(这在模拟器中默认开启,但值得检查)

In Safari, after you've started your phoneGap/cordova app and its loaded & running, access iPhone Simulator or your device from the Develop menu. You can enable Develop menu in Safari's Advanced Preferences, if its not already.

在 Safari 中,在您启动 phoneGap/cordova 应用程序并加载并运行后,从“开发”菜单访问 iPhone 模拟器或您的设备。您可以在 Safari 的“高级首选项”中启用“开发”菜单(如果尚未启用)。

More discussion at the bottom of: http://www.mobilexweb.com/blog/iphone-5-ios-6-html5-developers

更多讨论见底部:http: //www.mobilexweb.com/blog/iphone-5-ios-6-html5-developers

(also, if you read about a "secret private interface" somewhere, this doesn't work anymore.)

(此外,如果您在某处读到“秘密专用接口”,这将不再起作用。)

回答by dhaval

Try using weinre it is a really good tool to debug javascript applications on mobile devices.

尝试使用 weinre,它是在移动设备上调试 javascript 应用程序的一个非常好的工具。

http://people.apache.org/~pmuellr/weinre/docs/latest/

http://people.apache.org/~pmuellr/weinre/docs/latest/

Although you will still not be able to debug the script step-by-step as it gives on desktop but gives lot more detail than xcode (~ for javascript).

尽管您仍然无法像在桌面上那样逐步调试脚本,但提供的细节比 xcode(~ 用于 javascript)要多得多。