xcode 文件中的Xcode 8断点不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39922865/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 8 Breakpoint in file not working
提问by DerFlickschter
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
.
我SignInViewController.swift
在我的 Xcode 项目中有一个文件 ,它突然开始不在断点处停止。我有一个断点 inviewDidLoad()
和一些viewDidAppear()
. 我print()
在这两个函数中都有几次调用以确保它们正在执行。断点在其他文件(包括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.
当我试图找出问题所在时,我注意到在构建项目时会出现一个错误Invalid redeclaration of 'signInViewController.swift'
,然后在构建完成之前消失,应用程序将正常运行,除了文件中的断点. signInViewController.swift
是几个月前文件的旧名称,然后我将其重命名为SignInViewController.swift
. 在断点问题发生之前我没有看到它,并且由于我已经清理了项目的构建文件夹和 Xcode 的派生数据,我一直无法复制。我有一种感觉,它正在考虑问题,但我不确定如何/为什么。
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
- 清洁工程
- 清理构建文件夹
- 清除 Xcode 的 DerivedData
- 确保启用断点(Cmd Y)
- 构建设置设置为调试
- 始终显示启用和禁用反汇编
- 在运行配置中启用调试
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
- 尝试按照 neprocer 的回答在此处删除 Xcode 首选项
UPDATE 2:
更新 2:
I have isolated the breakpoint issue to just viewDidLoad()
and viewDidAppear()
breakpoints elsewhere in the file are working.
我已经分离断点问题,只是viewDidLoad()
和viewDidAppear()
文件中断点在别处工作。
UPDATE 3:
更新 3:
Isolated to a specific block of code in viewDidLoad()
. viewDidAppear()
still not working though.
隔离到viewDidLoad()
. viewDidAppear()
仍然无法正常工作。
采纳答案by DerFlickschter
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.
我不确定这最终是如何修复它的,但我将问题隔离到viewDidLoad()
. 然后我注释掉该代码并构建并运行该项目。然后我取消注释代码并再次构建并运行它,断点起作用了。
回答by neowinston
I had the same problem with an old project. Select Product(located at top menu bar) -> Scheme -> EditSchemeand I solved this issue by clicking on "Debug Executable", as shown in Picture. Maybe this will help someone else too.
我在一个旧项目中遇到了同样的问题。选择产品(位于顶部菜单栏)-> 方案-> 编辑方案,我通过单击“调试可执行文件”解决了这个问题,如图所示。也许这也会对其他人有所帮助。
回答by Renetik
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.
在我的情况下,断点没有在一个回调中被击中,所以我在项目目标构建设置中将“Swift Compiler”“Optimization Level”更改为“No optimization”以进行调试,并且它开始在 Xcode 9.3 和 AppCode 中工作。
回答by Renish Dadhaniya
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.
下面的补丁对我有用。从菜单栏中,选择Product -> Scheme -> Edit Scheme -> Select Profile -> Set Build Configuration to BUILD。请查看下面随附的屏幕截图。
回答by Magnus
I solved this by going to my Xcode project's 'Build Settings' and setting 'Generate Debug Symbols' to 'Yes'
我通过转到我的 Xcode 项目的“构建设置”并将“生成调试符号”设置为“是”解决了这个问题
回答by Fred Dijkstra
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.
对我有帮助的是删除位于以下目录中的项目目录 (*.xcodeproj) 下的文件 Breakpoints_v2.xcbkptlist:xcuserdata/Fred.xcuserdatad/xcdebugger(用您的用户名替换“Fred”)。使用终端程序去那里。
回答by Ali Azam
I was also dealing with the same issue in xcode 9.
我也在 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
使用以下终端命令删除 XCode 默认值
defaults delete com.apple.dt.Xcode.LSSharedFileList defaults delete com.apple.dt.Xcode
清除(或删除)Xcode 的 DerivedData
/Users/[Your Mac Username]/Library/Developer/Xcode/DerivedData
从应用程序中删除(或卸载)Xcode.app,然后重新启动PC
安装 Xcode 9 的新副本
[强制] 为您的应用项目设置用户权限,例如
chmod -R 777 "/Users/[Your Mac Username]/Desktop/TestApp/"
[其中 TestApp 是保留在桌面上的应用程序项目]
打开项目并检查 Build Settings 是否设置为 Debug
- 确保断点已启用并在代码中设置调试点
回答by neprocker
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
有时,Xcode 用户默认值本身中的值可能已更改,有时,我在调试器停止在堆栈跟踪时遇到类似问题很少有方法可以清除此问题
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
其他问题可能是目标的优化级别,将其更改为无将在调试器处停止
回答by Phu Nguyen
In my case, it turns out that the Devbuild configuration is not configured properly.
就我而言,事实证明Dev构建配置未正确配置。
The Devconfiguration should be copied from Debug, not Release.
在开发配置应该从被复制调试,而不是释放。
You can search with word debugin your Build settings
to see the differences.
您可以在您的单词debug中搜索Build settings
以查看差异。
For example:
例如:
Hope this helps.
希望这可以帮助。
回答by Sineth Lakshitha
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.
在标准编辑器中打开 viewController.swift 文件进行初始视图,并在 viewDidLoad 中打印一些内容并运行应用程序。如果打印正常,现在确保您在助手编辑器中正确选择了 viewController.swift 文件。