I am upgrading an app from PhoneGap 1.9 to PhoneGap 3.0. The console.log() function is not working anymore. Previously, the ouput was written in the XCode console. What\'s t
Problem
The following or a similar error message occurs when adding the console plugin to the ios platform (or after reinstalling) via Command-line Interface:
"CDVPlugin class CDVLogger (pluginName: Console) does not exist."
Solution
Open your Xcode project and go to the tab "Build Phases". Now open the drop-down named "Compile Sources". Click on the "+" sign at the end of the list and add "CDVLogger.m" or any other missing source.
You need the debug console plugin added to your project:
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git
In later versions of phonegap/cordova, to add the debug console plugin in your project:
cordova plugin add org.apache.cordova.console
I've found JSconsole.com extremely useful for remotely capturing console logs from mobile devices.
Heres how you set it up:
In you apps index.html, Include(change the ID):
<script src="http://jsconsole.com/remote.js?<MAKE UP SOME UNIQUE ID>"></script>
:listen <YOUR UNIQUE ID>
Open your app on your mobile device, you will see console logs on your computer.
I found GapDebug really useful. Unlike anything else [cough cough weinre], it let's you console log from your local app
If you have installed the Cordova console-plug-in, then when you run your app:
phonegap run iOS
you will find the logs at:
[your project dir]/platforms/ios/cordova/console.log
for IOS. All console logs show up as expected.
Besides adding the Console plugin I have another assumption why it might not work:
console.log in Phonegap is called asynchronously thus if a future call fails, the whole function fails and all log calls within are swallowed.
receivedEvent = function( id ) {
alert( 'This message is displayed because alert is called synchronously ')
console.log( 'This will not be displayed in Phonegap only in browser' )
callingAFunctionWhichDoesNotExist()
console.log( 'This will neither be displayed in Phonegap nor in browser' )
}