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:
- Clean Project
- Clean Build Folder
- Clear Xcode's DerivedData
- Making sure breakpoints are enabled (Cmd Y)
- Build Settings are set to Debug
- Always Show Disassembly enabled and disabled
- Debugging enabled in run config
Any help would be very much appreciated.
UPDATE 1 (still no luck):
- 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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With