Xcode 7 beta 调试器未在 Swift 代码的断点处显示变量值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31992079/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:40:27  来源:igfitidea点击:

Xcode 7 beta debugger not showing values of variable at breakpoint for Swift code

iosxcodedebugging

提问by Abdullah Umer

I have tried the answers from question herebut none of them helped :(

在这里尝试了问题的答案,但没有一个有帮助:(

I have installed Xcode 7 beta 5 and the debugger will not show values of variables when debugging swift code. It works fine in Obj-C code.

我已经安装了 Xcode 7 beta 5,调试器在调试 swift 代码时不会显示变量的值。它在 Obj-C 代码中运行良好。

I have tried changing the Compiler Optimisation level to None and it had not effect.

我尝试将编译器优化级别更改为无,但没有效果。

enter image description here

在此处输入图片说明

回答by Allan Weir

I was still finding this an issue in the final release of XCode 7.0. It turns out my bridging header needed updating as one of the references was no longer needed in it.

在 XCode 7.0 的最终版本中,我仍然发现这是一个问题。事实证明,我的桥接头需要更新,因为其中不再需要引用之一。

I found that out by using 'po' in the debugger for one of the variables, e.g. 'po self.views'. The debugger then listed all the errors in the bridging header for me. Weird way to find out the problem but it worked.

我通过在调试器中对变量之一使用“po”来发现这一点,例如“po self.views”。然后调试器为我列出了桥接头中的所有错误。找出问题的奇怪方法,但它有效。

EDIT: And just in case do a clean build after fixing any issues

编辑:以防万一在解决任何问题后进行干净的构建

回答by Mostafa Abdellateef

This may be due to a problem in the bridging file between Swift and Objective-C, e.g the file {projectName}-Bridging-Header.h . To make sure about that:

这可能是由于 Swift 和 Objective-C 之间的桥接文件存在问题,例如文件 {projectName}-Bridging-Header.h 。为了确保这一点:

1- add a breakpoint at the place you want to debug.

1- 在要调试的位置添加断点。

2- After the breakpoint is reached, write the lldb command poon any object in the xCode debugging output window. for example :

2- 到达断点后,在 xCode调试输出窗口中的任何对象上写入 lldb 命令po。例如 :

po self.view

If there is a problem you should see it's log and hopefully you can go and fix it

如果有问题,你应该看到它的日志,希望你可以去修复它

回答by Gent Berani

I had the same issue. I solved it from this link here:

我遇到过同样的问题。我从这里的链接解决了它:

Swift debugger does not show variable values when importing ObjC framework

Swift 调试器在导入 ObjC 框架时不显示变量值

First try to move in subfolder all .framework, as Author of this post says:

首先尝试在子文件夹中移动所有 .framework,正如这篇文章的作者所说:

I got a message from an Apple developer stating that they've observed this problem, and that it could be fixed by moving the .framework to a subfolder of the project. Apparently the module .. was built in directory error appears only if the .framework is in the same folder as the .xcodeprojaka $(PROJECT_DIR).

我收到了来自 Apple 开发人员的一条消息,指出他们已经观察到这个问题,并且可以通过将 .framework 移动到项目的子文件夹来修复它。显然,仅当 .framework 与.xcodeprojaka $(PROJECT_DIR)位于同一文件夹中时,才会出现模块 .. was built in directory 错误。

But in my case, the main issue was OpenTokframework. After I add action in the breakpoint

但就我而言,主要问题是OpenTok框架。在断点中添加动作之后

po self 

Log shows up the message:

日志显示消息:

warning: Swift error in module myapp: Swift had fatal errors constructing the ast context for this module: :1:9: note: in file included from :1: #import "/Users/me/Developer/myapp-ios/Pods/OpenTok/OpenTok.framework/Headers/OpenTok.h"

警告:模块 myapp 中的 Swift 错误:Swift 在为此模块构建 ast 上下文时出现致命错误::1:9:注意:在文件中包含:1:#import "/Users/me/Developer/myapp-ios/Pods/ OpenTok/OpenTok.framework/Headers/OpenTok.h"

And finally I added these lines of codes in Podfile:

最后我在中添加了这些代码行Podfile

post_install do |installer|
  `find Pods -regex 'Pods/OpenTok.*\.h' -print0 | xargs -0 sed -i '' 's/\(<\)OpenTok\/\(.*\)\(>\)/\"\2\"/'`
end

After that finally, pod install.

之后,终于,pod install

回答by Breek

Apple fixed this problem in Xcode 7 Beta 6

Apple 在 Xcode 7 Beta 6 中修复了这个问题

And there is a link about the problem from Twitter Developer: https://twittercommunity.com/t/xcode-7-debugger/50792

Twitter 开发人员提供了一个关于该问题的链接:https: //twittercommunity.com/t/xcode-7-debugger/50792

回答by matts

The thread that @Breek linked to contains the solution - Twitter has released a fix for this. Upgrading Crashlytics from 3.1.x to 3.2fixed the debugger for me on the Xcode 7 GM seed. If for some reason you cannot upgrade Crashlytics, you should be able to edit their header files as indicated in the thread as a temporary workaround; that is, changing #import <Fabric/FABAttributes.h>in Crashlytics.h to @import Fabric;instead.

@Breek 链接到的线程包含解决方案 - Twitter 已为此发布了修复程序。 将 Crashlytics 从 3.1.x 升级到 3.2为我修复了 Xcode 7 GM 种子上的调试器。如果由于某种原因您无法升级 Crashlytics,您应该能够按照线程中的指示编辑它们的头文件作为临时解决方法;也就是说,#import <Fabric/FABAttributes.h>在 Crashlytics.h 中@import Fabric;改为。

回答by Jin Wang

I had the same problem. The reason is because I'm using Crashlytics which is a ObjC framework.

我有同样的问题。原因是因为我使用的是 Crashlytics,它是一个 ObjC 框架。

Try to remove some of the ObjC frameworks and then shift + cmd + kto clean your project and rebuild it again.

尝试删除一些 ObjC 框架,然后shift + cmd + k清理您的项目并重新构建它。

It should work after that.

在那之后它应该可以工作。

回答by Mayur Rathod

Goto Project -> Targets -> Build Setting -> Optimisation Level -> Debug and set value to whatever u want

转到项目 -> 目标 -> 构建设置 -> 优化级别 -> 调试并将值设置为您想要的任何值

回答by rjb101

Removing Fabric/Crashlytics did it for me. I can say for sure not ALL ObjC imports cause this problem. I'm still using some others in my Swift project but for some reason Crashlytics causes some issues in the latest beta. I got a compiler error early on too and I had to turn off bitcode for the project to even compile.

删除 Fabric/Crashlytics 为我做到了。我可以肯定地说并不是所有的 ObjC 导入都会导致这个问题。我仍在 Swift 项目中使用其他一些,但出于某种原因,Crashlytics 在最新的测试版中引起了一些问题。我也很早就遇到了编译器错误,我不得不关闭项目的位码才能编译。