Xcode 8 Breakpoint in file not working

爷,独闯天下 提交于 2019-12-18 14:09:36

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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.




回答6:


I solved this by going to my Xcode project's 'Build Settings' and setting 'Generate Debug Symbols' to 'Yes'




回答7:


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

  • Make sure breakpoints are enabled and set debug point in your code



回答8:


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




回答9:


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.




回答10:


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.




回答11:


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.



来源:https://stackoverflow.com/questions/39922865/xcode-8-breakpoint-in-file-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!