Inhereted project.. NSLog does not print to console - iphone

I was given a project file and after opening it up I have noticed NSLog does not print to the console.
I've tried shift + command + c and that didn't work.
The strange thing is if I open any other project they print to console just fine still. However this one does not. Is this an xcode setting? if so why is it only this one project that is effected? and how do I go about fixing it?

1) newer attempt to help
Make sure you're printing out everything from NSLog. There's a toggle you can set in the console window:
2) original attempt to help
Try doing a "#undef NSLog" at the top part of your code and see if "NSLog" works again.
If so, then Dave is correct... you need to search around your code to see where "NSLog" has been redefined.

I know this is an old thread, but I just experienced a case where NSLog suddenly stopped displaying. I don't know what actually caused it but, in my case, a simple restart of Xcode made the problem go away. Just posting in case it helps somebody else.

Related

Remote Swift Package: Xcode won't pause at this breakpoint because it has not been resolved [duplicate]

Shortly after updating to Xcode 13.2.1 I started seeing some weird behaviour of breakpoints. When I run an app (in a simulator) some of my breakpoints change their look and turn to dotted blue outlined. Xcode does not stop execution at these breakpoints although code has been compiled, loaded and executed. I checked it in Console by adding some prints.
When I hover over breakpoint Xcode shows a message:
Xcode won't pause at this breakpoint because it has not been resolved
Resolving it requires that:
The line at the breakpoint is compiled.
The compiler generates debug information that is not stripped out (check the Build Settings).
The library for the breakpoint is loaded.
All trivial solutions like reloading, reapplying breakpoints have not helped.
Did anybody else see something like this? Is there a way to solve it?
Screenshot for reference:
Ok, so in my particular case rebooting laptop has helped. All breakpoints are now good. But it would still be nice to know the cause of the problem.
Make sure that the file in which you are adding breakpoint is having correct target set in target membership.
Click on .m file in which you want to add breakpoint.
Select the file inspector.
Check if you have selected correct target for that file or not (check below image).
What worked for me, was to select the files, delete them with - Delete>Move To Trash - and then drag the files back from the trash to the project.
In my case the issue was happening, because class was not added to the target, which I was trying to build.
For my case somehow the code path was never invoked and very likely considered as dead code. The same thing applies when not adding the file to the target that you want to debug.
This can be the case or somehow debugger might not be able to resolve your breakpoint. The first thing in this case should be cleaning derived data and any caches.
But instead of recloning your repo you can just delete breakpoint config from the location described in this answer
In Xcode 14 the problem is much more prevalent and "consistent". I figured out one pattern where it always fails and how to mitigate it.
If you have a final class then breakpoints set on or inside a private method will have that issue. If you remove private from the method or final from the class the breakpoints will get resolved properly.
If tried everything and nothing worked I suggest the following:
Reclone your repo
This is what worked for me.
I just passed through this problem and the solution for me was recreating the files.
Note: The ones I was trying to originally breakpoint on were copied from another project. When I created the new files, even though their Identity and Type looked just the same (target membership, encoding, paths), for some reason breakpoints started to work again.
Note 2: When copying and pasting code to your new files (if done manually), migrated breakpoints - created in the older file - will continue to fail. Only the ones created in this new file will work properly.
Hope it helps.
My case
Working on framework development. Framework is injected into the sample app for development/run purpose. Breakpoints inside the framework won't work.
Fix
Just removing xcframework in sample app and replacing with framework.
Reason
xcframework are precompiled outside of the app, so lib isn't compiled when project is built and that's why breakpoints doesn't work.
For me reboot the Xcode, and it works~

EXEC BAD ACCESS shows no trace/logs even with NSZombiesEnabled set to YES

I'm not exactly sure how to debug this but it seems that I'm getting EXEC BAD ACCESS in the main function of my app. There's no trace or logs of what's going on. I have NSZombiesEnabled but it doesn't seem to be showing anything. How would I debug this?
The first step in debugging is to find out where the crash happens. To do this you need to be able to reproduce the bug.
The Xcode debugger will usually tell you where the crash happened. It doesn't happen in main(), that's simply the entry point for the app and the top of the call stack. You can zoom in to the call stack with the slider at the bottom of the Debugger pane (in Xcode 4).
If the stack trace doesn't include any of your own code, then you may need to set an exception breakpoint in the Breakpoints pane and try again.
If all else fails, you'll have to do some digging:
1) Find a reproducible case where you can make the app crash every time (or almost every time) using the same actions.
2) Since you know what you're doing to make the app crash, you roughly know where in the code you should look. Set breakpoints at strategic places (or use NSLog). After some fishing, you'll find the exact line where the app crashed.
3) Fix the problem. :-)
It may be helpful.
Mainly you are getting this error because you have released something which is useful in furthur.So try to focus on the release.comment the line where you have used the release
Have you tried too clean and rebuild your project, and restart XCode. Latest versions of Xcode sometimes does EXEC BAD ACCESS int the main function with no reasons…
Turns out, pushing multiple view controllers simultaneously will cause this. Hard to debug that!

nslog stopped working in xcode

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
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...
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.
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
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)
In the view select Debug Area
(There are 3 view buttons, on the top right hand corner of Xcode, press the center button)
Select "Show variables view and the console"
(In the debug area (bottom) there are ther 3 buttons, press the center button)
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.
Try changing the dropdown menu at the bottom of the console to 'All Output'.
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.
some steps :-
1) "Clean all targets" or delete your build and rebuild again.
2) If step 1 doesnt work , reinstall xcode

Xcode 4, debugging, breakpoints, NSLogs

I am hoping someone can help me. I have just started running xcode 4.01 and for some reason whenever I run an app, it does not stop on breakpoints or display the NSlog messages. I have a message in my viewDidLoad and it never shows. I even breakpoint on this log and the best I can get in the output window is:
pending breakpoint 1 - "universalTestAppDelegate_iPad.m:15" resolved
pending breakpoint 2 - "universalTestAppDelegate_iPhone.m:16" resolved
Actual code is:
-(void) viewDidload
{
NSLog("in viewDidLoad");
}
So it appears it sees the breakpoint but never stops on it. As I said, brand new to xcode 4 so any idea on what I am doing wrong? Uninstalled and reinstalled and still nothing. Also, if it means anything, in the Scheme to choose where to run, I can select IOS devie, iPad 43 simulator and iPhone 4.3 simulator. Tried both and still nothing. Why can't I select/see other versions of the IOS?
BTW: The above is because I do not have my iPad or iPhone connected. Thanks in advance for any and all help.
Geo...
Your method is just never called.
Make it
-(void) viewDidLoad
with big "L" and your chances of "breaking" will sky rocket. ;)
Two possibilities:
You don't have breakpoints turned on. Use the Product->Debug->Activate Breakpoints command to rectify this.
You have breakpoints turned on but you placed your breakpoints on lines that haven't been executed. If your log statement doesn't appear in the console, that would indicate that the method containing that statement isn't executing, so it's no surprise that the breakpoint on that line has no effect.
I had similar issue where the debugger would not stop on breakpoints in the simulator using Xcode 4C199. Turns out the simulator was just buggered and restarting it resolved the issue.
I also had the issue with XCode 3 where I had localized the name of the app to a set of Japanese characters. The debugger didn't like that. I solved that one by having english name for debug configuration and japanese name for release.

My breakpoint is not working please give me some suggestions as to why not

While debugging the program my breakpoint is not working, so please give me some advice so that it can work properly.
Maybe you've tried to use the breakpoint on unreachable code? Try setting your breakpoint somewhere before the point you want to reach and try stepping from there to see if the point is actually reached.
Possible Reasons could be.
1. After changes in the code you have not built the libraries properly so the breakpoint is not pointing to the right location in the code.
2. If you are putting a breakpoint in a library then make sure the library is build and is built in Debug mode.
3. Clean full environment and rebuild the project.
Open XCode preferences and in the Debugging tab, un-check "Load symbols lazily", this caught me out when I first started iPhone developement. Then again, it might be for any of the other reasons that people have already mentioned.