Cannot debug Swift module/framework embedded in Ob

2019-03-09 18:18发布

Alternative titles (to aid searching)

  • Cannot debug Swift 2.3 framework linked to an Objective-C app in Xcode 8
  • error in auto-import: failed to get module 'XYZ' from AST context Xcode 8
  • Xcode 8 cannot debug Swift framework
  • warning: Swift error in module <XYZ>
  • Workaround for; Xcode Debugger cannot debug apps written in Objective-C only but that link against frameworks written in Swift only. (28312362)

I have an app written in Objective-C that links against some modules (frameworks) written in Swift 2.x.

Question

Everything (debugging etc.) works fine in , however when moving to and updating the modules to use I was unable to debug the modules.

LLDB reported these errors:

warning: Swift error in module XYZ.
Debug info from this module will be unavailable in the debugger.

error: in auto-import:
failed to get module 'ABC' from AST context

This does not happen if I link the modules to an app built in Swift 2.3.

11条回答
劫难
2楼-- · 2019-03-09 18:40

For me it was just as simple as it was painful and time consuming:

import SDWebImage was the PROBLEM, because one of the frameworks had the SDWebImage already packed in it(and I couldn't see it), and that framework happened to be Objective-C, and the app was Swift. I also added the SDWebImage to the project, because I use it in the classes I write, and that what created the mess the xCode debugger couldn't deal with. So basically, make sure you don't have ANYTHING duplicated in ANY way, I'd check for common things like SDWebImage for example.

查看更多
叼着烟拽天下
3楼-- · 2019-03-09 18:44

In my case, I had to remove Objective-C Bridging header from build settings file. My Bridging header file did not do anything.. so it was okay.

查看更多
仙女界的扛把子
4楼-- · 2019-03-09 18:46

I ran into this when building a framework with Carthage. Trying to debug would print the error, which referenced an Obj-C framework dependency.

I found this blog post which suggested adding a the following user-defined build setting to my project:

For Debug: REMOVE_HEADERS_FROM_EMBEDDED_BUNDLES = NO

For Release: REMOVE_HEADERS_FROM_EMBEDDED_BUNDLES = YES

This fixed the issue for me.

查看更多
萌系小妹纸
5楼-- · 2019-03-09 18:47

Try to restart Xcode. In my case it resolved an issue.

查看更多
【Aperson】
6楼-- · 2019-03-09 18:48

I just took 2 days for me to resolve and debugging through print command all the time. Now I got the issue:

My project is in Swift and I was using objective-C library same as imported in pods for swift(old Objective-C project merged in this one) and was using import IQKeyboardManager as well as import "IQKeyboardManager.h" header as well. That conflicts and deleting the header one resolved my issue finally. You can check with this type of duplicity in libraries.

查看更多
登录 后发表回答