Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 8 Breakpoint in file not working

Tags:

I have one file,SignInViewController.swift, in my Xcode project that out of nowhere has begun not stopping on breakpoints. I have a breakpoint in viewDidLoad() and a few in viewDidAppear(). I have several print() calls in both functions to make sure they are executing. Breakpoints work fine in other files including AppDelegate.swift.

There was a point when I trying to figure out what was wrong where I noticed that while I was building the project an error would appear saying Invalid redeclaration of 'signInViewController.swift' and then go away before the build finished and the app would run fine, except for the breakpoints in the file. signInViewController.swift is the old name of the file from months ago before I renamed it to SignInViewController.swift. I haven't seen it before until the breakpoint issue occurred and since I have cleaned the project's build folder and Xcode's derived data I have been unable to replicate. I have a feeling that it is factoring into the problem but I am not sure how/why.

Anyways, here is things I've tried already. Most of them are just for breakpoints not working in general but I figure I should list them anyways even though that is not the case:

  1. Clean Project
  2. Clean Build Folder
  3. Clear Xcode's DerivedData
  4. Making sure breakpoints are enabled (Cmd Y)
  5. Build Settings are set to Debug
  6. Always Show Disassembly enabled and disabled
  7. Debugging enabled in run config

Any help would be very much appreciated.

UPDATE 1 (still no luck):

  1. Tried deleting the Xcode preference as suggested by neprocker's answer here

UPDATE 2:

I have isolated the breakpoint issue to just viewDidLoad() and viewDidAppear() breakpoints elsewhere in the file are working.

UPDATE 3:

Isolated to a specific block of code in viewDidLoad(). viewDidAppear() still not working though.

like image 410
DerFlickschter Avatar asked Oct 07 '16 17:10

DerFlickschter


People also ask

Why breakpoint is not working in Xcode?

You might be pushing "Run" instead of "Debug" in which case your program is not running with the help of gdb, in which case you cannot expect breakpoints to work! In Xcode 6.4, there is now only a Run button and whether it runs a debug configuration or not depends on the currently selected scheme settings.

Why is breakpoint not working?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.

How do I enable breakpoints in Xcode?

Xcode displays a breakpoint icon to indicate the location. Drag a breakpoint up or down to move it to another location; drag it away from the gutter to remove it. Click the breakpoint icon in the debug area toolbar to activate or deactivate all breakpoints.

How do I activate breakpoints?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint.


1 Answers

I had the same problem with an old project. Select Product(located at top menu bar) -> Scheme -> EditScheme and I solved this issue by clicking on "Debug Executable", as shown in Picture. Maybe this will help someone else too.

enter image description here

like image 169
neowinston Avatar answered Dec 14 '22 23:12

neowinston