Swift 调试器在导入 ObjC 框架时不显示变量值 [英] Swift debugger does not show variable values when importing ObjC framework

查看:35
本文介绍了Swift 调试器在导入 ObjC 框架时不显示变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 Sprite Kit 创建一个新的 OS X游戏"项目,并在任何我能看到变量值的地方设置断点时:

然后我更改代码以导入我自己的框架 (TilemapKit),它是一个纯 Objective-C 框架:

import SpriteKit导入 TilemapKit类 GameScene:SKScene {覆盖 func didMoveToView(view: SKView) {打印(当!")}}

未进行其他更改.我什至没有使用任何 TilemapKit 代码(还).当断点触发时,我看到:

就观察变量值而言,整个项目不再可调试.这种行为是完全一致的.如果没有框架导入,我可以再次调试.

由于我使用的是 Xcode 7 beta (7A121l) 和 OS X 10.11 开发者预览版,我知道这可能只是一个(临时)错误.

命令行瓷砖设置为使用 Xcode 7.0 版本顺便说一句.我尝试在框架目标中启用模块,确保部署目标相同(10.11),禁用符号剥离.我添加了一个桥接头并在其中 #imported TilemapKit 框架(在这种情况下删除 Swift 导入仍然会为我提供不可调试的应用程序,因此我导入框架的方式或位置似乎无关紧要).

有人对可能导致这种行为的原因以及我如何解决它提出建议 - 或者至少我可以尝试缩小问题范围吗?

罪魁祸首是否更有可能与项目和框架的构建设置有关?我是否需要在应用程序项目中启用某些内容以使其与 ObjC 框架兼容?(我已经在其他链接器标志中获得了 -ObjC)

<小时>

更新:

我在调试控制台中运行了po self,发现了这个提示:

<built-in>:3:6: 错误:模块TilemapKit"内置在目录/TilemapKit.framework"中,但现在驻留在目录./TilemapKit.framework"中#define __clang_major__ 7^缺少必需的模块TilemapKit"来自该模块的调试信息在调试器中将不可用.

框架构建目录怎么变了?为什么这很重要以及如何解决这个问题?

PS:在一个新的 ObjC 应用中同样的框架可以很好地调试.

解决方案

我收到了来自 Apple 开发人员的消息,称他们已经观察到此问题,并且可以通过将 .framework 移动到项目.

显然,module .. was built in directory 错误仅在 .framework 与 .xcodeproj aka $(PROJECT_DIR) 位于同一文件夹中时才会出现.>

然而,将框架移动到子文件夹并没有解决我的问题,但在更新的 Xcode 7 测试版中解决此问题之前仍然值得一试(仍然出现在测试版 3 中).

When I create a new OS X "Game" project with Sprite Kit, and set a breakpoint anywhere I can see the variable values just fine:

Then I change the code to import my own framework (TilemapKit) which is a pure Objective-C framework:

import SpriteKit
import TilemapKit

class GameScene: SKScene {
    override func didMoveToView(view: SKView) {
        print("dang!")
    }
}

No other changes made. I'm not even using any of the TilemapKit code (yet). When the breakpoint triggers, I see this:

The entire project stops being debuggable as far as observing variable values goes. This behavior is perfectly consistent. Without the framework import I can debug again.

Since I'm on Xcode 7 beta (7A121l) and OS X 10.11 developer preview I know this could simply be a (temporary) bug.

Command line Tiles are set to use the Xcode 7.0 version btw. I tried enabling modules in the framework target, made sure the deployment target is the same (10.11), disabled symbol stripping. I added a Bridging Header and #imported the TilemapKit framework in it (removing the Swift import in that case would still give me the non-debuggable app, so it doesn't seem to matter how or where I import the framework).

Does anyone have a suggestion on what could cause this behavior and how I might go about fixing it - or at least how I could try to narrow down the issue?

Is the culprit more likely to be connected to the project's vs the framework's build settings? Do I need to enable something in the app project to make it compatible with ObjC frameworks? (I already got -ObjC in the Other Linker flags)


UPDATE:

I ran po self in the debug console and found this notice:

<built-in>:3:6: error: module 'TilemapKit' was built in directory '/TilemapKit.framework' but now resides in directory './TilemapKit.framework'
#define __clang_major__ 7
     ^
missing required module 'TilemapKit'
Debug info from this module will be unavailable in the debugger.

How come the framework build directory changed? And why would that matter and how to fix this?

PS: the same framework in a new ObjC app can be debugged just fine.

解决方案

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 .xcodeproj aka $(PROJECT_DIR).

However moving the framework to a subfolder didn't fix the issue in my case, but it's still worth a try until this gets fixed in a newer Xcode 7 beta (still occurs in beta 3).

这篇关于Swift 调试器在导入 ObjC 框架时不显示变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆