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

后端 未结 11 1700
悲哀的现实
悲哀的现实 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:51

    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.

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

    As suggested by Tim https://stackoverflow.com/a/41876400/1840269 the root cause to our problem was a matter of duplicates.

    We had a obj-c wrapper category for SDWebImage that was used from both obj-c and Swift. When Importing the category from Swift everything blew up because of redefinition/duplicate import since the SDWebImage pod already exposed it self as a Swift module.

    The solution? We re-implemented the obj-c category as a Swift extension - and kept using it from both Swift and obj-c by adding @objc in front of the extension and importing the #import "product-Swift.h" file from obj-c.

    And maybe start with checking: https://developer.apple.com/library/content/qa/qa1947/_index.html.

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

    I discussed this issue with an Apple engineer named Sean at WWDC 2017.

    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.

    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 anymore (new->file->Swift file, don't create the bridging header. The file will only contain the import of Foundation).

    And that's it. Problem solved.

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

    In my case there was a compiler error in the "C" code which was reported in LLDB, after fixing the error LLDB started working again.

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

    use fr v instead po for debugging

    For more debugging https://www.codeproject.com/Articles/1181358/Debugging-with-Xcode

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