console.log is not working in iOS Phonegap App even after adding the console plugin

一曲冷凌霜 提交于 2019-12-05 07:06:33

I have solved this issue by doing these steps

Step 1 :

I Just copy a directory from another cordova project where console.log was working

sudo cp -r DIFF_CORDOVA_PROJECT_PATH/platforms/ios/www/plugins/org.apache.cordova.console CURRENT_CORDOVA_PROJECT_PATH/platforms/ios/www/plugins/

Step 2 :

Add the Code in CURRENT_CORDOVA_PROJECT_PATH/platforms/ios/www/cordova_plugins.js file under module.exports JSON array

{
    "file": "plugins/org.apache.cordova.console/www/console-via-logger.js",
    "id": "org.apache.cordova.console.console",
    "clobbers": [
        "console"
    ]
},
{
    "file": "plugins/org.apache.cordova.console/www/logger.js",
    "id": "org.apache.cordova.console.logger",
    "clobbers": [
        "cordova.logger"
    ]
}

Step 3 :

Adding Meta data on the same cordova_plugins.js file in module.exports.metadata JSON Array :-

"org.apache.cordova.console": "0.2.7"

In my case the reason was probably because the plugin was installed from a Windows machine the first time and it work previously only for the Android platform. when I try to reinstall it from my Macintosh I encountered the same problem of Shashi.

This has been caused from the missing of the source file CDVLogger.m in the compile source list. So I recommend to check if this file is already added by:

Click on root Project file in the Xcode explorer > Build Phases > Compile Sources section

If the CDVLogger.m file is not present add it and try to Run the project again. This fixed the issue for me.

EDIT: In addition be sure that your index.html page contains this HTML:

<div id="deviceready" class="blink">
    <p class="event listening">Connecting to Device</p>
    <p class="event received">Device is Ready</p>
</div>
mboeckle

I tried a lot of solutions posted here in stackoverflow but nothing was working for me. After putting the cordova.js outside of my personal JS folder console.log was working fine.

<script charset="utf-8" src="cordova.js"></script>

add <script type="text/javascript" src="cordova.js"></script> inside the section of the code

Chris Emerson

I've had this as well. I would get no console output and my app's default.html file would never really load. The issue in my situation was that my console plugin was literally one decimal off/old (0.2.12 instead of 0.2.13). Soon as I updated everything started working again... argh!

Related: https://stackoverflow.com/a/32035260/826308

Make sure you do following action:

function onDeviceReady() {
if (window.cordova.logger) {
    window.cordova.logger.__onDeviceReady();
} } document.addEventListener('deviceready', onDeviceReady, false);`
Baljeet Singh

In my case, following div was missing

<div id="deviceready" class="blink">
  <p class="event listening">Connecting to Device</p>
  <p class="event received">Device is Ready</p>
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!