Reputation: 1059
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.
Upvotes: 23
Views: 19960
Reputation: 713
Open viewController.swift file for initial view in the standard editor and print something inside viewDidLoad and run application.. if the print is working properly, now make sure you have selected viewController.swift file correctly in the assistant editor.
Upvotes: 2
Reputation: 10752
Below patch is work for me. From the menu bar, select Product -> Scheme -> Edit Scheme -> Select Profile -> Set Build Configuration to BUILD. Please review below-attached screenshot.
Upvotes: 8
Reputation: 7764
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.
Upvotes: 31
Reputation: 331
Building up on what @neprocker said, I had "Optimize for Speed" for both debug/release. Simply changed the value for debug and I was good to go.
Upvotes: 1
Reputation: 2115
I was also dealing with the same issue in xcode 9.
I resolved the issue in below ways:
Remove XCode defaults Using below terminal command
defaults delete com.apple.dt.Xcode.LSSharedFileList
defaults delete com.apple.dt.Xcode
Clear(or delete) Xcode's DerivedData from
/Users/[Your Mac Username]/Library/Developer/Xcode/DerivedData
Delete(or uninstall) Xcode.app from Applications and then restart PC
Install fresh copy of Xcode 9
[Mandatory] Set user permission to your app project like
chmod -R 777 "/Users/[Your Mac Username]/Desktop/TestApp/"
[where TestApp is the app project keeping on Desktop]
Open the project and check Build Settings are set to Debug
Upvotes: 7
Reputation: 261
In my case, it turns out that the Dev build configuration is not configured properly.
The Dev configuration should be copied from Debug, not Release.
You can search with word debug in your Build settings
to see the differences.
For example:
Hope this helps.
Upvotes: 2
Reputation: 6373
In my case breakpoint was not hit in just one callback, so I changed "Swift Compiler" "Optimization Level" to "No optimization" in project target build settings for debug, and it started working in Xcode 9.3 as well as AppCode.
Upvotes: 17
Reputation: 173
I solved this by going to my Xcode project's 'Build Settings' and setting 'Generate Debug Symbols' to 'Yes'
Upvotes: 6
Reputation: 61
What helped for me was deleting the file Breakpoints_v2.xcbkptlist which is located under the project directory (*.xcodeproj) in the directory: xcuserdata/Fred.xcuserdatad/xcdebugger (replace "Fred" with your username). Use a terminal program to go there.
Upvotes: 6
Reputation: 1059
I'm not really sure how this ended up fixing it but I isolated the issue to a specific block of code in viewDidLoad()
. Then I commented out that code and built and ran the project. Then I uncommented the code and built and ran it again and the breakpoints worked.
Upvotes: 6
Reputation: 170
Sometimes the values may have changed in Xcode userdefaults itself, At times, I had similar issue with debugger stopping at stacktrace Few ways to clear this
1.Delete the Xcode preference
defaults delete com.apple.dt.Xcode
Other Issue could be the optimization level for the target, changing it to none will stop at the debugger
Upvotes: 3