xcode 8 Debugger 'Could not resolve type'

徘徊边缘 提交于 2019-12-22 03:11:02

问题


In Xcode 8, When any break point is hit, and I try to print any object in the Xcode debugger, it always prints "Could not resolve type". I have searched enough on the internet. I have checked if EditScheme->Run->Info->BuildConfiguration is set to 'Debug'. Build setting->Optimisation level is set to 'None'. But no clues on why this happens. Could anyone help me out here? Thanks in advance.


回答1:


I encountered a similar issue with a pure swift framework that doesn't have any bridging headers but non the less had SWIFT_INSTALL_OBJC_HEADER set to YES

It is described in more detail at https://stackoverflow.com/a/51186560/385307

After changing the setting to NO debugging works again.




回答2:


I had a similar issue with a Swift project which included an Obj-C framework. I had imported the framework in my Swift project using

import Obj-C-Framework

Additionally, I had also created a Bridging-Header file in the Swift project and included the Obj-C-Framework header using

#include <Obj-C-Framework/Obj-C-Framework.h>

This was causing the Xcode debugger to always show 'could not resolve type' when printing objects in breakpoints. Removing the #include in the Bridging-Header fixed the issue and objects print correctly in breakpoints.

TL;DR If your swift project uses an Obj-C framework make sure that the framework headers are not included in your Swift project's bridging header.




回答3:


I just had the same problem and it had been solved.My project is a Mixed project with both OC and Swift. I found that some .h file import in my Bridging Header file that caused the problem. Definitely, an enum declared in the .h file cause the problem, like this:

typedef NS_ENUM(NSInteger,BadgeAlignment) {
    AlignmentCenter,
    AlignmentLeft,
    AlignmentRight,
};

If i comment the code, everything goes alright.

And I just add a prefix to each element of the enum and the problem is solved for me.

typedef NS_ENUM(NSInteger,BadgeAlignment) {
    BadgeAlignmentCenter,
    BadgeAlignmentLeft,
    BadgeAlignmentRight,
};

I just thinking if there is a conflict with some enum in Swift when convert the .h to Swift.

I'm still confused...



来源:https://stackoverflow.com/questions/41037921/xcode-8-debugger-could-not-resolve-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!