Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
131
rated 0 times [  134] [ 3]  / answers: 1 / hits: 17092  / 10 Years ago, mon, february 17, 2014, 12:00:00

I have created a Phonegap iOS App in Cordova CLI . I have added the console plugin and yes deviceready is called successfully but console.log is not working and does not print any thing in XCode log.



Plugin Installation :-




cordova -v

3.3.1-0.3.1



sudo cordova plugins add org.apache.cordova.console

Fetching plugin org.apache.cordova.console via plugin registry

Starting installation of org.apache.cordova.console for ios

Preparing ios project

org.apache.cordova.console installed on ios.



sudo cordova plugins ls

[ 'org.apache.cordova.console',

'org.apache.cordova.device',

'org.apache.cordova.dialogs',

'org.apache.cordova.geolocation',

'org.apache.cordova.globalization',

'org.apache.cordova.inappbrowser',

'org.apache.cordova.media',

'org.apache.cordova.network-information',

'org.apache.cordova.splashscreen',

'org.apache.cordova.vibration' ]




Java Script :-



var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
receivedEvent: function(id) {
console.log('Device Ready Received'); //It is not working
alert(Device ready called); //It is Working
}
};

More From » ios

 Answers
63

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


[#72484] Saturday, February 15, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yvettel

Total Points: 517
Total Questions: 101
Total Answers: 102

Location: Vanuatu
Member since Wed, Oct 14, 2020
4 Years ago
;