console.log not working in an iOS PhoneGap 3.0 app

后端 未结 8 1386
庸人自扰
庸人自扰 2020-12-14 02:00

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

相关标签:
8条回答
  • 2020-12-14 02:44

    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.

    0 讨论(0)
  • 2020-12-14 02:45

    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

    0 讨论(0)
  • 2020-12-14 02:45

    I've found JSconsole.com extremely useful for remotely capturing console logs from mobile devices.

    Heres how you set it up:

    1. In you apps index.html, Include(change the ID):

        <script src="http://jsconsole.com/remote.js?<MAKE UP SOME UNIQUE ID>"></script>
      
    2. On your computer, Go to jsconsole.com and type :listen <YOUR UNIQUE ID>

    Open your app on your mobile device, you will see console logs on your computer.

    0 讨论(0)
  • 2020-12-14 02:59

    I found GapDebug really useful. Unlike anything else [cough cough weinre], it let's you console log from your local app

    0 讨论(0)
  • 2020-12-14 03:00

    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.

    0 讨论(0)
  • 2020-12-14 03:01

    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' )
      }
    
    0 讨论(0)
提交回复
热议问题