5
votes

I have a strange issue and possibly a bug. My NSLog statements have stopped working completely, they do not print even in view did load, application didfinishlaunching etc. The have all turned a brown colour (the same colour as a pragma mark in xcode) and they all have a warning saying 'expression result unused'. Has anyone ever seen this before or know what to do? Am i running in some kind of weird mode? Im running xcode 4.0.2.

Many thanks

Jules

8
Have you tried closing and reopening Xcode? It sometime gets mad ...marzapower
xcode 4.0.2 is indeed a bit buggy... but anyway, are you sure it's not getting redefined somewhere? you can try cmd+clicking on NSLog to see if it leads you to any "non-standard" definition...André Morujão
tried restarting xcode, restarting machine, no non standard definition either. Im confused?Jules
I don't know what's going on but here are some ideas. Do an Edit > Find in Workspace (⇧⌘F) and look for #define NSLog to see if NSLog is redefined elsewhere. The XCode console part of NSLog is just a fprintf, there is no reason it should stop working unless it is redefined or redirected with freopen. The expression result unused part means what it says, and a common cause is to use something like *var++ instead (*var)++.Jano
I don't think it should have been there (unless it's now part of the code templates in xcode?), but anyway I'm guessing the goal for that was that when the code goes to production, in case you left any NSLog calls lying around, they're basically removed (because that's what defining NSLog to "nothing" does). Personally I prefer to use my own log macro and control it via a DEBUG preprocessor macro in my debug configuration. See: iphoneincubator.com/blog/debugging/…André Morujão

8 Answers

7
votes

for completeness, I had the same problem and the answer was different, hope it helps someone else who bumps into this post:

I had a framework (an Amazon one) redefining NSLog, went there (Cmd+Click on the Brown NSLog) and commented out the redefinition...

6
votes

The actual problem was the release_build set to 1. So it wasn't recognizing nslog, as you said it was set for a release build.

2
votes

I had the same issue :

what worked for me is given below:

  • Remove the derived data folder
  • After removing derived data perform the clean action (You can see this option in the product menu)

  • Quit the Xcode and start it again.

And this did the trick all my NSLog were working fine.

Hoep this helps

1
votes
  1. Ensure that scheme chosen corresponds to Debug mode because sometimes the pch file might have some definitions such that logging is done only in the debug mode (Scheme is on to the left of the place where you select iPhone Simulator / iOS Device)

  2. In the view select Debug Area (There are 3 view buttons, on the top right hand corner of Xcode, press the center button)

  3. Select "Show variables view and the console" (In the debug area (bottom) there are ther 3 buttons, press the center button)

0
votes

I had the same issue and the problem was that I was building an Ad Hoc version (schema was for Ad Hoc build). The warnings disappeared when I built for debug.

0
votes

Try changing the dropdown menu at the bottom of the console to 'All Output'.

Screenshot

0
votes

if you are using libraries like 'KScan' or 'iKEA' or 'kdc-scan', so it can happens that, they will call methods like this one 'redirectNSLogToDocuments'.

in my case the object of 'iKEA' call the method 'CheckIfDeviceConnected' and this one redirect all nslog outputs to documents. after commenting out, all nslogs works again :)

hope this will be useful for some one.

-1
votes

some steps :-

1) "Clean all targets" or delete your build and rebuild again.

2) If step 1 doesnt work , reinstall xcode