nslog stopped working in xcode - iphone

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

Related

Breakpoints are not working in Xcode 12.2

I have breakpoints set throughout my program, but Xcode appears to ignore them completely.
I wanted to create a new question, because this one was asked in 2008 and has nothing up-to-date.
Perhaps you've accidentally turned off the master breakpoint switch.
It should be bright blue, not gray. Click it to toggle.
This happened to me for a very odd reason. I added rich notifications to my app. As I ran the app I was running it on one of their targets instead of the main app itself. The orange arrow points to the main target. In a situation like this make sure you aren't on the wrong target (the ones above and below the orange arrow.

Why in Xcode 6 doesn't work Assistant Preview?

Sometimes in Xcode 6 Assistant Editor -> Preview stops working.
Showing just "No selection" even if no errors and Storyboard is ok.
Why does this happen?
The reason is "?" (questionmark) in Project's name (maybe there is a bug with other symbols – didn't check it).
You can try to rename Project or just create new one with name without "?" in it.
You must to Kill Xcode from processes for complete and then open it again. You can do it with Activity Monitor o CLI. Voila! - Preview is working again.
Don't just close Xcode keeping the app working. Sometimes also works closing with CMD + Q.
I had similar problem, but fixed it
You must open the xib or storyboard file in both assistant editors. Click the navigation button in the second editor (either the bottom or the right editor, depending on how you stack the assistant editors) and choose Preview to get the preview to appear.
thanks to
http://meandmark.com/blog/2014/09/xcode-6-no-simulate-document-in-interface-builder/comment-page-1/#comment-2883
I have played with Xcode 6 for a while and I encountered similar problems occasionally. I never used special characters in project or class names but the problem sometimes happens.
Now I have to test all ViewControllers at starting point to see if the Assistant Editor work. If not, I will just delete the class file and recreate the same one, it usually fix the problem.
Hope this can be fixed soon.

Playground is not showing result on right bar

I waited long time but my playground project is not showing result on right side bar
I am using right code but still right bar is not updating i don't know what is the problem i tried lot of time.
here is my code
var str = "Hello, playground"
var str1 = "this is my first program"
let kermit = "kermit"
let msPiggy = "ms. piggy"
let string1 = msPiggy + " and " + kermit + ", sitting in a tree"
let string2 = "\(msPiggy) and \(kermit), sittting in a tree "
let string3 = " kermit has \(5*2) fingers"
let chr1:Character = "💿"
As of Xcode 8, unless you are print-ing out things, results in the playground could take a little bit more work to show.
In this screenshot, I show two things you can click on. #1 is the the "Show Debug Area" button, the middle button in the top right of the toolbar (i.e. which toggles the lower pane that slides up and down in the Xcode window). Results from print end up there.
Also, the second set of (multiple) circles shows that you can click on to show results. You can slide the gray bar space wider to make things show.
Lastly, where you see the "Play" triangle in the lower toolbar, try clicking on that to force the Playground to execute your code again.
In my case, I had to close Xcode 9.2 and close all simulators, then restart playground file, then it worked.
I am also facing this problem as shown in below image
There is no log on the right bar
So what we do :
We just Quit Xcode and again open playground project
and it works fine
also, there is one more button through which you can set automatically and manually run
If you have M1 chip MacBook Pro, you have to uncheck Rosetta to get the Playground working.
My result area was somehow too narrow to show the results. Try dragging it larger.
It's not the assistant editor that should be enabled. It's the little grey bar to the right that is too narrow. If you hover your mouse pointer just next to an expected result, you will see the familiar little eye and radio button icon. Then drag the bar out and it'll show.
Hope it works!
I had the same issue, and discovered that if I held down the Play icon above the debug area (revealed at the bottom of the playground), it had an option, 'Automatically Run'.
I selected that, and all is well!
Cheers.
add import PlaygroundSupport to the top of your code! i had the same issue and it worked perfectly.
In Xcode 10.1 I changed build system to Legacy Build System from file > Playground Setting. It fixed my problem
In my case I have two Xcode versions installed on my mac. (v8.2.1 and v7.3.1)
The two Xcode is running simultaneously, and then when I decided to open a playground on v8.2.1 and printed out some codes. Playground should run it automatically but it is stuck in Running my file.
What I did is I restarted both of my Xcode applications and then Playground succesfully printed my codes.
https://forums.developer.apple.com/thread/3672
playground will not show results if any of your previous lines has error, you will have to remove those errors and all the results would immediately start showing up on right side bar.
In my case for Xcode 9.2, output started appearing when I clicked File/New/Tab. So, Playground seems missing some refresh option and new tab did that.
oftentimes, I need to close my playground and Xcode and relaunch it again to see the results.
Also had this problem. "Editor › Run Playground" worked for me.
In my case i ensured i set the right Command Line Tool version by tapping Xcode>Preferences>Locations and it worked.
i made a checklist to resolve this issue
First of all make sure your 'result area' is not hidden, There
should be some grey (result area) on right side, if whole
screen is white then try to pull it from right-edge of screen.
Make sure there is no code error, you can check code error in 'debug
area'.
If both point are resolve though you can not see result then try to
print('hello world') at last.
In my case, I was saving my playground somewhere else than the default path and it didn't show the result. Saving it on the default path made it work.
In my case,
ios: macOS Catalina Version 10.15.7
Xcode
Version 12.1 (12A7403)
1.First Go to Editor then click run playgound
2.Then it will show the running results on the right side.
With Xcode 12+, please uncheck Open using Rosetta.
I saved my playground to the folder of my choosing, all the solutions to save it in default location are simply silly...
I did have enabled the right-hand side area and console-output on the bottom.
Whether running from Edit->Run Playground or using Cmd+Return didn't help, still no output was shown. Even though my code was solid and I could see Build Succeed in the top notificaiton area...
After checking Preferences->Locations I could see there are no Command Line Tools seleceted, so I choosed only one available option (Xcode 13.2.1) and... still no output...
Then I closed XCode with Cmd+Q and started it again...
Finally it worked and output was shown...

Xcode 4 is no longer showing me where my warnings are?

Xcode 4 has stopped showing me the locations of build warnings that I have. How can i get it to start showing me them again?
Make sure you're looking in the right place. On the left-hand side of Xcode (4), look for the little error symbol. Click it and enjoy your errors in all their glory.
If you click on the errors and it doesn't take you to the location in code, I think something must be messed up with your Xcode install. I remember you had another question earlier about Xcode problems, so it wouldn't hurt to uninstall & reinstall.
In Xcode 4.3.1. I have one project that doesn't show any warnings, but others do.
So it's not an Xcode issue I guess.
In the Issue Navigator (⌘4) be sure to clear the filter at the bottom left of the screen:
Just click on the x at the right, at the filter will be removed -- worked for me!
Check the below SO post
(iphone) Is there a way to see compile output of xcode4?
press command + 4 for issue navigator. (there are two filter here "By File" and "By Type")

Xcode's Refactor menu is always disabled

For some reason Xcode's Refactor is always disabled. I used to be able to activate it via selecting a class name and right clicking in the editor to select it. But now no matter what I do, it remains disabled. Any idea what's going on?
Working with Xcode 5, I kept getting "Can't refactor during indexing" when trying to refactor. Rebuilding the index seemed to hang at "Indexing - Waiting for make" forever.
I then noticed that make was already used by another process on my machine (not by Xcode). Shutting this process down enabled Xcode to finally finish indexing
Your project's index might be out of date/corrupt. In the General tab of the Project Settings window, click Rebuild Code Index and wait until it's done.
You can check the progress of the rebuild in the Activity window (Window > Activity).
I just ran into a similar problem in Xcode. I could not refactor anything in the class's .m (implementation file). The only explanation I could come up with is that it was not indexing the file for some reason, and I could not force it to reindex. The only hack that I found that worked was to copy the file to temporary location, remove it from my Xcode project, copy the file from the temp location back to my project's location, and then re-add the file via Xcode.
None of these suggestions work for Xcode 3.2 - the ONLY way is to select the file you want to rename in the left Groups & Files column. THEN highlight the name of the .m or .h in the right code view, then you can right click and select Refactor!
For instance if you're changing the DetailViewController name, highlight the actual DetailViewController.h word in code.
Note, you should also always make sure you've selected the .h file, not the .m
I faced the same thing in Xcode 11. and this worked for me:
I changed iPhone 8 simulator to generic iOS Device and it worked when it is on Generic
I'm new in iOS development,I have met this similar problem.
Xcode:Version 7.1 (7B91b),it looks like Refactor not working:
But when I put my mouse on the red circle point in the following picture,and then the Refactor working.
I think this is a low level mistake,but may be a reference for someone.