ios Cordova 2.9、3.0 没有 console.log
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17735084/
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
Cordova 2.9, 3.0 no console.log
提问by inorganik
With a fresh download of Cordova 2.9 and the Cordova CLI, I created Hello World application via the CLI. I also added the iOS platform via the CLI. Looking in the index.js file (within www/js), there is a javascript object which contains the function that fires onDeviceReady
, and a function inside it, which contains a console.log which should output "Received Event: deviceready".
通过全新下载 Cordova 2.9 和 Cordova CLI,我通过 CLI 创建了 Hello World 应用程序。我还通过 CLI 添加了 iOS 平台。查看 index.js 文件(在 www/js 中),有一个 javascript 对象,其中包含 fires 的函数onDeviceReady
,以及其中的一个函数,其中包含应输出“ Received Event: deviceready”的 console.log 。
After running this app from Xcode in the iOS 6.1 simulator, there is no output from the console.log in Xcode's debug console. I looked at the cordova.js file and noticed the CLI platform add
utility added 3.0 (ran this yesterday, before the 3.0 release), but I tried running the app with cordova-2.9.0.js as well.
在 iOS 6.1 模拟器中从 Xcode 运行此应用程序后,Xcode 的调试控制台中的 console.log 没有输出。我查看了cordova.js 文件并注意到CLIplatform add
实用程序添加了3.0(昨天在3.0 版本之前运行),但我也尝试使用cordova-2.9.0.js 运行该应用程序。
Anyway, I haven't been able to get a console.log in my own application or the Hello World app to display in Xcode's console with cordova 2.9 or 3. My Xcode console is set to All Output. Is this an error with the release? From all the googling I've been doing, it seems Cordova has had on and off support of console.log depending on the version and I don't know where it's supposed to be now. Thanks for your help.
无论如何,我无法在我自己的应用程序或 Hello World 应用程序中获得 console.log 以在 Xcode 的控制台中使用cordova 2.9 或 3 显示。我的 Xcode 控制台设置为所有输出。这是发行版的错误吗?从我一直在做的所有谷歌搜索来看,Cordova 似乎已经根据版本对 console.log 进行了断断续续的支持,我不知道它现在应该在哪里。谢谢你的帮助。
回答by danieldkim
The console functionality is now implemented as a plugin, which you need to manually add to your project:
控制台功能现在作为插件实现,您需要手动将其添加到您的项目中:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git
回答by Hoa Hoang
try to add Debug Console plugin to your project by running this command:
尝试通过运行以下命令将调试控制台插件添加到您的项目中:
$ cordova plugin add org.apache.cordova.console
回答by inorganik
The problem is because of the command line utility. There are two ways to create a project with the PhoneGap/Cordova CLI - Use the bash scripts that come with PhoneGap folder you download, and (2) to install the Cordova CLI.
问题是因为命令行实用程序。有两种方法可以使用 PhoneGap/Cordova CLI 创建项目 - 使用您下载的 PhoneGap 文件夹附带的 bash 脚本,以及 (2) 安装Cordova CLI。
I used the Cordova CLI, which doesn't use any resources you download, it downloads the latest release of PG - in this case 3.0, which isn't available yet on phonegap.com. It's very possible it may not be a stable release, because the console.log didn't work in the iOS app it created.
我使用了 Cordova CLI,它不使用您下载的任何资源,它下载最新版本的 PG - 在这种情况下是 3.0,在 phonegap.com 上尚不可用。它很可能不是稳定版本,因为 console.log 在它创建的 iOS 应用程序中不起作用。
I tried using the batch script in the 2.9 folder I downloaded, and it created an app with fully functional console.log(ging).
我尝试使用我下载的 2.9 文件夹中的批处理脚本,它创建了一个具有全功能 console.log(ging) 的应用程序。
回答by Benjamin Conant
This turned out to be a 2 hour long problem for me so I thought I would share the love! I fresh installed Cordova 3.0
and then installed the official console log plugin with
结果证明这对我来说是一个长达 2 小时的问题,所以我想我会分享这份爱!我全新安装Cordova 3.0
,然后安装了官方控制台日志插件
cordova plugin add cordova-plugin-console
cordova plugin add cordova-plugin-console
But I still could not get Safari to show logs by going to
但是我仍然无法通过转到 Safari 来显示日志
Safari > Develop > IOS simulator > index.html
Safari > Develop > IOS simulator > index.html
So I opened up Xcode
and checked the system log
File > New Log Window > system.log
于是我打开Xcode
查看系统日志
File > New Log Window > system.log
...system.log
is on the left hand side of the popup under the Files
section.
...system.log
位于该Files
部分下弹出窗口的左侧。
There I noticed that there was a log reading
在那里我注意到有一个日志读数
Oct 14 01:12:57 Bens-MacBook-Pro.local ios-sim[37222]: stderrPath:
/Users/benconant/Dev/FirstCordovaApp/platforms/ios/cordova/console.log
so I ran
所以我跑了
tail -F /Users/benconant/Dev/FirstCordovaApp/platforms/ios/cordova/console.log
in a new terminal window and boom ... got my logs!
在一个新的终端窗口中,繁荣......得到了我的日志!
Still have no idea how to get them from Safari :( Would welcome any hints at how to make that happen. Good luck ... this was/is a ruff one.
仍然不知道如何从 Safari 获取它们 :( 欢迎任何有关如何实现这一点的提示。祝你好运......这是/现在是一个粗鲁的人。