Cannot debug Swift module/framework embedded in Objective-C app

后端 未结 11 1699
悲哀的现实
悲哀的现实 2021-02-01 02:57

Alternative titles (to aid searching)

  • Cannot debug Swift 2.3 framework linked to an Objective-C app in Xcode 8
  • error in auto-import: f
相关标签:
11条回答
  • 2021-02-01 03:33

    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.

    0 讨论(0)
  • 2021-02-01 03:35

    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.

    0 讨论(0)
  • 2021-02-01 03:39

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

    0 讨论(0)
  • 2021-02-01 03:43

    tl:dr

    Add a user defined setting under "Build Settings" for your app target.

    SWIFT_VERSION = 2.3

    More Info

    I'm unsure if this is an Xcode 8 bug or if it's Apple policy (to try an force developers to Swift 3.0?). But... by default Xcode 8 installs the Swift 3.0 versions of the standard Swift runtime libraries.

    When it comes to debugging with LLDM the Swift 2.3 modules fail to load (in to the Swift 3.0 runtime).

    Forcing the app to use Swift 2.3 (or legacy Swift as Apple call it), fixes the issue.

    Swift apps have this setting exposed by Xcode but you have to manually add it for an Objective-C app.

    Further Advice

    Port your Swift 2.3 code to Swift 3.0 as soon as possible, Apple won't support 2.x for very long.

    0 讨论(0)
  • 2021-02-01 03:47

    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.

    0 讨论(0)
  • 2021-02-01 03:50

    I ran into the error in auto-import: failed to get module 'XYZ' from AST context message while attempting to debug in an 9.3 simulator. Switching to a 10.2 simulator resolved the issue.

    0 讨论(0)
提交回复
热议问题