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.
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.
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.
我通过转到我的Xcode项目的'Build Settings'并将'Generate Debug Symbols'设置为'Yes'来解决这个问题
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
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
在标准编辑器中打开viewController.swift文件以获取初始视图,并在viewDidLoad中打印一些内容并运行应用程序..如果打印工作正常,请确保在助手编辑器中正确选择了viewController.swift文件。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.