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

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

问题描述

当我用Sprite Kit创建一个新的OS XGame项目,并在任何位置设置一个断点,我可以看到变量值很好:





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

  import SpriteKit 
import TilemapKit

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

没有其他更改。我甚至没有使用任何TilemapKit代码(还)。当断点触发时,我看到这样:





只要观察变量值为止,整个项目将停止可调试。这个行为是完全一致的。没有框架导入,我可以再次调试。



由于我在Xcode 7 beta(7A121l)和OS X 10.11开发者预览我知道这可能只是一个)错误



命令行瓷砖设置为使用Xcode 7.0版本btw。我尝试在框架目标中启用模块,确保部署目标是相同的(10.11),禁用符号剥离。我添加了一个桥接头,并在其中引用了TilemapKit框架(删除Swift导入在这种情况下仍然会给我不可调试的应用程序,所以似乎不重要我或者导入框架)。有没有人有什么建议可能导致这种行为,以及我如何去修复它 - 或者至少我可以尝试缩小问题?



歹徒更有可能连接到项目与框架的构建设置?我需要在应用程序项目中启用某些内容以使其与ObjC框架兼容吗? (我已经在其他链接器标志中有-ObjC)






更新:



我在调试控制台中运行 po self ,发现此通知:

 < built-in>:3:6:error:module'TilemapKit'内置在目录'/TilemapKit.framework'中,但现在位于目录'./TilemapKit.framework '
#define __clang_major__ 7
^
缺少所需的模块'TilemapKit'
调试器中的这个模块的调试信息将不可用。

框架构建目录如何更改?为什么这么重要,如何解决这个问题?



PS:新的ObjC应用程序中的框架可以调试正常。

解决方案

我收到了苹果开发者的消息,指出他们已经观察到了这个问题,可以通过将.framework移到子文件夹项目。



显然,模块..内置在目录中,仅当.framework位于同一文件夹.xcodeproj aka $(PROJECT_DIR)



但是将框架移动到子文件夹并没有解决问题在我的情况下,但是仍然值得一试,直到在更新的Xcode 7 beta(仍然发生在beta 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).

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

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