Can't see console log messages on xCode

Hello

I have an app which works in the browswer; now I want to deploy it as app for ios so I added the ios platform, the plugins (device and console) as shown in the tutorial. However no output from console.log is shown in the xcode debug area…any hint?

2 Likes

Hi, facing the same pb.

Form my controller, nothing is displayed:

$ionicPlatform.ready(function() { var injector = angular.element( document.body ).injector(); var $log = injector.get( "$log" ); $log.info( "Ionic Platform ready" ); $log.error( "error: Ionic Platform ready" ); console.log('LOG: testazeazeaeazeazeazeazeazeazeazea'); console.warn('WARN: testazeazeaeazeazeazeazeazeazeazea'); console.error('error: testazeazeaeazeazeazeazeazeazeazea'); });

Install this:

cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git

If it doesn’t work from there, you may have an issue with it binding, but I’ve never had problems with it.

2 Likes

try this:
$ ionic plugin add org.apache.cordova.console

Thanks for the different answers. I did:

$ ionic plugin add org.apache.cordova.console

But now when I launched: “sudo ionic build iOS” I got the following error:

The following build commands failed:
	CompileC build/front.build/Debug-iphonesimulator/front.build/Objects-normal/i386/CDVLogger.o front/Plugins/org.apache.cordova.console/CDVLogger.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

ERROR building one of the platforms: Error: /Users/syo/WebstormProjects/fives_front/platforms/ios/cordova/build: Command failed with exit code 65
You may not have the required environment or OS to build this project

===========

Error is because the folder a folder and file are missing:

lang: error: no such file or directory: '/Users/syo/WebstormProjects/fives_front/platforms/ios/front/Plugins/org.apache.cordova.console/CDVLogger.m'

I tried to add it again via:

sudo cordova plugin add org.apache.cordova.console

but it says it’s already installed

1 Like
  1. Make sure sudo has write permissions to the folder (sometimes they get turned off for whatever reason)
  2. REMOVE the plugin, then re-add it.
  3. If that still doesn’t work then you’ve maybe accidentally or purposely corrupted the Xcode projects so you’ll want to remove the iOS platform, then add it back.

you can use safari developer tool to view your device console logs

2 Likes

I was able to make by:

  • 1/ creating manually missing folder
  • 2/ copy missing *.h and *.m files

===

But unfortunately, I don’t have anything in the console windows of xCode

I don’t really know what happened, but I do know see my log message into the xCode console : )

1 Like

You just save my mac! I was going to throw it down the window because I was unable to test notifications without checking the console. Now it is working!

1 Like

@nnnnnorthhhhh, I’ve tried your suggestions on iOS 10 but it didn’t work. Have you noticed any problems when using this plugin on iOS 10? Thanks.

I use it on IOS 10, Xcode 8 and my logs show up just fine (they don’t without it, which is what the plugin is for)
cordova-plugin-console 1.0.3 “Console”

@pliablepixels, strange… for me, none of my “console.log()” calls are shown in the Xcode logs. The only thing that helped me in that matter was this.

These are my installed Cordova plugins:

cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.4 "Console"
cordova-plugin-device 1.1.3 "Device"
cordova-plugin-geolocation 2.3.0 "Geolocation"
cordova-plugin-splashscreen 4.0.0 "Splashscreen"
cordova-plugin-statusbar 2.2.0 "StatusBar"
cordova-plugin-whitelist 1.3.0 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

This is my environment (ionic info):

Cordova CLI: 6.3.1
Ionic Framework Version: 1.1.0
Ionic CLI Version: 2.0.0
Ionic App Lib Version: 2.0.0
ios-deploy version: 1.9.0 
ios-sim version: 5.0.8 
OS: Mac OS X El Capitan
Node Version: v6.6.0
Xcode version: Xcode 8.0 Build version 8A218a

I know this is basic but it might be worth checking if you have the Xcode debug window enabled/displayed? Also are you building a debug build or a release build? I think in release builds console logs are stripped via scripts in the hooks folder (not sure about this)

@pliablepixels, when I run the ionic build ios --device command, it prints Configuration: Debug (see below):

iMac-de-Carlos:IonicGeolocation carlosballock$ ionic build ios --device
Running command: /Developer/IonicGeolocation/hooks/after_prepare/010_add_platform_class.js /Developer/IonicGeolocation
add to body class: platform-ios
Building project: /Developer/IonicGeolocation/platforms/ios/IonicGeolocation.xcodeproj
	Configuration: Debug
	Platform: device

So, I think it’s a debug build.

The log window I refer to is this one with the log records:

Is it the same you are referring to?

The strange thing is that when I change the output type from “All Output” to “Debugger Output” in the log window’s bottom combo-box, the logs get empty.

@pliablepixels, I don’t know what I’ve just did, but now it’s working… 8) Thanks for your help, anyway!

1 Like