Xcode 4 and debugging - ios

I've setup a break point (Left click in gutter) in some methods. I've also wired the control to the method (in IB). However when I press CMD + R, it ignores my breakpoints. How do I make Xcode stop at breakpoints?

Click on Activate/Deactivate Breakpoints to deactivate breakpoints and activate it again. Then Build and Debug. If it still doesn't work then remove Breakpoints and add breakpoint again (this is what worked for me when gdb doesn't hit the breakpoint)

Related

Thread1: Breakpoint 1.4 [duplicate]

I am following the Stanford University iOS development course on iTunes U.
In one of the demos (that I have been trying to follow), there is this code that loads the property list from an NSURL and returns it as NSMutableDictionary.
-(NSMutableDictionary *) words
{
NSURL *wordsURL=[NSURL URLWithString:#"http://cs193p.stanford.edu/vocabwords.txt"];
words=[[NSMutableDictionary dictionaryWithContentsOfURL:wordsURL] retain];
return words;
}
The application is successfully built, but at runtime it gives the following error and gets stuck:
I can't figure out what the problem is. Can you please help?
You're stopped at a breakpoint. That's a debugging tool, not an error. See the blue arrow/tab in the left margin, where the line numbers are? Drag that away and drop it anywhere (you'll see a "poof") to remove it, then run your project again.
You can also deactivate all breakpoints by typing ⌘-Y, the key equivalent for the menu item Debug>Deactivate Breakpoints, or you can view all your breakpoints in the Breakpoint Navigator (hit ⌘-6).
When execution stops like this, you can continue from the breakpoint, either by typing continue at the debugger prompt in the Console:
(lldb) continue
Or hitting the "Play" button in the debugger controls. You can also type Control-⌘-Y, which is the equivalent for the menu item Debug>Continue.
This isn't an error. You just set a breakpoint (probably without knowing it).
Drag the little blue Chevron in the column at the left out of the way. You will see it disappear and go poof, and then you can rebuild your app and you should see it run properly.
Now, that said, I think there are some memory management mistakes in your code, but we can return to those later. ;-)
The program is stopping because you have a breakpoint.. That's the blue arrow on the left of the code. Right-click it and delete.

iOS TodayView Widget breakpoints not working

I'm working through this tutorial and it works just fine on a simulator, except I don't understand how the methods are being called. The today view widget displays fine but when I add breakpoints to the methods (e.g. ViewDidLoad, widgetPerformUpdateWithCompletionHandler) the breakpoints never seem to be called.
I'm trying to figure this out as I've added extra code - e.g. NSLog to display some values within the methods but do not see any output from the NSLog calls.
Can someone explain why the breakpoints are not working? I'm guessing that it has something to do with the extension methods are executing in the 'background' but am not sure.
Thanks
You are able to have the breakpoints you set in your today extension activate by following the procedure below:
1) Set breakpoint in your extension code (viewDidLoad is a good option to test)
2) Launch your app as you normally would by selecting your app's target and hitting run.
3) Make sure that your extension is installed in the today view (open the today view and hit the edit button to add it if it is not)
4) Close the today view.
5) In Xcode select your today extension target and press the run button. You will be prompted to choose an app to run. Select "Today".
6) You should see the today window appear on the simulator (this also works on the device). Your breakpoint will be hit.
NOTE: You may hit an exception breakpoint in your app prior to the today extension launching because your app is sent to the background. If this happens just skip over the breakpoint and you will hit the breakpoint in your extension as expected. This procedure also allows you to see console statements from your extension.
I'm not sure if this is related to your specific situation, but in an app where I have 3 extensions, I noticed that breakpoints don't work in 2 of them.
I noticed however, that the breakpoints start working if I run (from XCode) the extension on which the breakpoints work, and access one of the other extensions (from inside Photos app in my case). For some reason, running the other extensions from XCode would not trigger the breakpoints.

Is there a way to see which line of code was just executed in Xcode?

I'm debugging an iOS app in Xcode, and I'm wondering is there any way to see which line of code I just ran? I'm trying to figure out where the code is that is responsible for making a menu slide open when I tap the menu key.
Thanks
Set a breakpoint (tap on a line number in Xcode) and manually run the code line by line using Xcode's Debug menu. In your case you can set a breakpoint on the method that is executed when a button is pushed. If you do not know which method is called when you push the button, you could look at where the button is declared, which should have a addTarget method, or see what it is hooked up to in the Storyboard.
If you have a few places where you think the code is executed, you can use NSLog() statements and see what is being printed to the console at what time.

How to set the exception breakpoint in xcode 6

hi after crashing i set the exception break point by pressing break point symbol and i choose objective c language while editing the break point. I run it again ,app is crashed ,but it is not stopped where the exception is occurred in xcode6
Thanks in advance.
Ok than try using enabling zombie environment.
Follow these steps:
Click on project name and edit scheme.
A pop over will appear, In that select Arguments tab. See bottom section Environment Variables. You can see + button at bottom part. Click on that button and add varialbe NSZombieEnabled with value YES.
Now from same popover select Diagnostics tab. And mark Enable Zombie Objects.
Click close and again run your project, hope this will track down zombie objects at runtime which cause runtime crash.
See the following steps.
Look into [Navigator] and Click on [Show the Breakpoint Navigator].
See the bottom of Navigator [ + ] Sign. Click on it
Select [Add Exception Breakpoint].
Your Exception Breakpoint are activated from this things.

How do I delete a breakpoint marker in xcode?

So my app is 100% done, however when I compile it in xcode the app loads up normal, but when I press the button, which is the apps main function, it encounters a thread breakpoint error and I'm not sure why.
When I run the app by itself in the simulator without xcode it runs perfect, the thread error only happens when I run it in xcode.
Thanks again for any help that can be provided!
Click on that dark blue arrow next to the "Play Sound" comment, and it will turn light blue (disabled). Or right click (or option-click) on the blue arrow and you have an option to remove the breakpoint.
Or select the breakpoint navigator ("View" - "Navigators" - "Show Breakpoint Navigator") and manage your breakpoints there.
See WWDC 2012 video Debugging in Xcode.
Your app stops when running in the debugger because you have set a breakpoint at that line. Delete or disable the breakpoint. There is nothing wrong here and there is no error. The debugger is doing exactly what you told it to do.
In XCode 9 the easiest way to delete breakpoint is to just left-click and drag it.

Resources