unable to print object ('po') in xcode6 be

2019-03-08 09:17发布

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

(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.

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

5条回答
神经病院院长
2楼-- · 2019-03-08 09:49

Have same issue in 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.

查看更多
够拽才男人
3楼-- · 2019-03-08 09:51

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.

查看更多
相关推荐>>
4楼-- · 2019-03-08 10:00

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.

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.

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.

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.

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).

查看更多
做个烂人
5楼-- · 2019-03-08 10:03

I'd recommend double-checking that you have the

-D DEBUG

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.

查看更多
何必那么认真
6楼-- · 2019-03-08 10:04

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

查看更多
登录 后发表回答