无法打印xcode6 beta 6 osx swift项目中的对象(“po”):(自动导入错误:无法从AST上下文中获取模块“__ObjC”)

时间:2022-04-06 20:52:34

An attempt to print object (po command) in xcode 6 beta 6 OSX Swift project results in this error message:

在xcode 6 beta 6 OSX Swift项目中,尝试打印对象(po命令)会导致此错误消息:

(lldb) po managedObject
error: Error in auto-import:
failed to get module '__ObjC' from AST context

In this case the object in question is an instance of NSManagedObject.

在这种情况下,问题中的对象是NSManagedObject的一个实例。

Any advice on how to help auto-import in getting __ObjC module into LLVM Abstract Syntax Tree context?

关于如何帮助自动导入将__ObjC模块导入LLVM抽象语法树上下文的建议?

5 个解决方案

#1


24  

As of Xcode 6.1 if you attempt the po command twice it will work on the second attempt. The first po command will always fail for each new debugging session but subsequent calls work.

在Xcode 6.1中,如果您尝试两次po命令,它将进行第二次尝试。对于每个新的调试会话,第一个po命令总是失败,但是随后的调用工作。

#2


7  

Have same issue in xcode 7.3.1:

在xcode 7.3.1中有同样的问题:

error: Error in auto-import:
failed to get module 'Touch' from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2/libxml/tree.h"
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2/libxml/tree.h:17:10: error: 'libxml/xmlversion.h' file not found
#include <libxml/xmlversion.h>
         ^
could not build Objective-C module 'LibXML2'

But you can use fr v managedObject instead of po managedObject.

但是可以使用fr v managedObject而不是po managedObject。

#3


3  

I'd recommend double-checking that you have the

我建议你仔细检查一下。

-D DEBUG

- d调试

flag set under 'Other Swift Flags' for the scheme that you're using to debug. I experienced similar issues when I'd accidentally deleted it.

用于调试的计划的“其他Swift标志”下的标志。当我不小心把它删除时,我也遇到了类似的问题。

#4


1  

A clean of my project and deleting DerivedData worked for me.

清理我的项目并删除了DerivedData为我工作。

#5


1  

I discussed a similar error message with an Apple engineer at WWDC2017. It seems like this issue can have many causes, and I am aware that mine is slightly different than the one described above.

我在WWDC2017上与一位苹果工程师讨论了类似的错误信息。似乎这个问题有很多原因,我知道我的问题和上面描述的稍有不同。

My team spent weeks trying to figure this out, and it ended up being a bug on Apple's compiler, which we could never have figured out by ourselves. Also, it has a VERY easy workaround.

我的团队花了几个星期的时间试图解决这个问题,结果却成了苹果的编译器上的一个bug,而我们自己根本就搞不懂。而且,它有一个非常简单的解决方法。

So, this is just me posting the fix here, in order to maximize the probability that someone else does a search for this confusing error message, and finds this answer.

所以,这只是我在这里发布的补丁,为了最大限度地增加其他人搜索这个令人困惑的错误消息的概率,并找到这个答案。

So, here it is. In our case, we had an Objective-C project using a mix of Swift and Objective-C frameworks. This fix might apply in slightly different contexts, just try it.

所以,在这里。在我们的案例中,我们使用了一个使用Swift和Objective-C框架的Objective-C项目。这个修复可能适用于稍微不同的上下文,只要尝试一下。

There happens to be a bug with the way the compiling flags get aggregated from the frameworks and the project, and the "pure Objective-C" project "activates" it.

当编译标志从框架和项目中聚合时,会出现一个bug,而“纯粹的Objective-C”项目会“激活”它。

Solution: add one single, empty Swift file ("Whatever.swift", or whatever) in your Objective-C project, making it not-pure-objective-c any more (new->file->Swift file, don't create the bridging header. The file will only contain the import of Foundation).

解决方案:添加一个单一的、空的Swift文件。在你的Objective-C项目中,让它不再是objective- Objective-C(新的>文件-> swift文件,不要创建桥接头)。该文件只包含基础的导入。

#1


24  

As of Xcode 6.1 if you attempt the po command twice it will work on the second attempt. The first po command will always fail for each new debugging session but subsequent calls work.

在Xcode 6.1中,如果您尝试两次po命令,它将进行第二次尝试。对于每个新的调试会话,第一个po命令总是失败,但是随后的调用工作。

#2


7  

Have same issue in xcode 7.3.1:

在xcode 7.3.1中有同样的问题:

error: Error in auto-import:
failed to get module 'Touch' from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2/libxml/tree.h"
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2/libxml/tree.h:17:10: error: 'libxml/xmlversion.h' file not found
#include <libxml/xmlversion.h>
         ^
could not build Objective-C module 'LibXML2'

But you can use fr v managedObject instead of po managedObject.

但是可以使用fr v managedObject而不是po managedObject。

#3


3  

I'd recommend double-checking that you have the

我建议你仔细检查一下。

-D DEBUG

- d调试

flag set under 'Other Swift Flags' for the scheme that you're using to debug. I experienced similar issues when I'd accidentally deleted it.

用于调试的计划的“其他Swift标志”下的标志。当我不小心把它删除时,我也遇到了类似的问题。

#4


1  

A clean of my project and deleting DerivedData worked for me.

清理我的项目并删除了DerivedData为我工作。

#5


1  

I discussed a similar error message with an Apple engineer at WWDC2017. It seems like this issue can have many causes, and I am aware that mine is slightly different than the one described above.

我在WWDC2017上与一位苹果工程师讨论了类似的错误信息。似乎这个问题有很多原因,我知道我的问题和上面描述的稍有不同。

My team spent weeks trying to figure this out, and it ended up being a bug on Apple's compiler, which we could never have figured out by ourselves. Also, it has a VERY easy workaround.

我的团队花了几个星期的时间试图解决这个问题,结果却成了苹果的编译器上的一个bug,而我们自己根本就搞不懂。而且,它有一个非常简单的解决方法。

So, this is just me posting the fix here, in order to maximize the probability that someone else does a search for this confusing error message, and finds this answer.

所以,这只是我在这里发布的补丁,为了最大限度地增加其他人搜索这个令人困惑的错误消息的概率,并找到这个答案。

So, here it is. In our case, we had an Objective-C project using a mix of Swift and Objective-C frameworks. This fix might apply in slightly different contexts, just try it.

所以,在这里。在我们的案例中,我们使用了一个使用Swift和Objective-C框架的Objective-C项目。这个修复可能适用于稍微不同的上下文,只要尝试一下。

There happens to be a bug with the way the compiling flags get aggregated from the frameworks and the project, and the "pure Objective-C" project "activates" it.

当编译标志从框架和项目中聚合时,会出现一个bug,而“纯粹的Objective-C”项目会“激活”它。

Solution: add one single, empty Swift file ("Whatever.swift", or whatever) in your Objective-C project, making it not-pure-objective-c any more (new->file->Swift file, don't create the bridging header. The file will only contain the import of Foundation).

解决方案:添加一个单一的、空的Swift文件。在你的Objective-C项目中,让它不再是objective- Objective-C(新的>文件-> swift文件,不要创建桥接头)。该文件只包含基础的导入。