xcode 如何使用 Cordova 和 ios 模拟器调试 js 代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14506160/
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
How can I debug js code using Cordova and ios simulator?
提问by Harry
I am using xcode 4.5.2 and PhoneGap (Cordova) to develop an iphone app.
我正在使用 xcode 4.5.2 和 PhoneGap (Cordova) 来开发一个 iphone 应用程序。
Looking at the Log Navigator
in xcode does not show me any of the js console.log
s.
查看Log Navigator
in xcode 并没有向我展示任何 js console.log
。
What must I do to be able to see these log outputs?
我必须做什么才能看到这些日志输出?
回答by Niall Paterson
This may be a little late but its quite simple.
这可能有点晚了,但它很简单。
So in Safari, Go preferences
-> advanced
-> Show Develop menu in menu bar
. Once you've that, build and run in xcode and then in safari go Develop
-> iPhone Simulator
-> Your App Name
.
所以在 Safari 中, Go preferences
-> advanced
-> Show Develop menu in menu bar
。完成后,在 xcode 中构建并运行,然后在 safari go Develop
-> iPhone Simulator
-> 中运行Your App Name
。
It works pretty well but I can't find a way to make it persist as such, so you need to repeat this after every run seemingly, which is a pain. If I find a way I'll post here.
它工作得很好,但我找不到一种方法让它持续下去,所以你似乎每次运行后都需要重复这个,这很痛苦。如果我找到一种方法,我会在这里发布。
Additional:
额外的:
As Harry points out below in the comments, you can then run location.reload
in the safari console to reload the Cordova app and see all the log messages from the boot of the application
正如 Harry 在下面的评论中指出的那样,然后您可以location.reload
在 safari 控制台中运行以重新加载 Cordova 应用程序并查看应用程序启动时的所有日志消息
回答by Lil'Monster 987
I found a little help to open the console for ios simulator
我找到了一些帮助来打开 ios 模拟器的控制台
http://blog.persistent.info/2014/06/adding-keyboard-shortcuts-for.html
http://blog.persistent.info/2014/06/adding-keyboard-shortcuts-for.html