Swift class ambiguity when importing frameworks

Viewed 856

I'm currently migrating some of sources in our projects, and cannot compile the project.

Here's the current configuration:

  • Two projects: main & library
  • An internal framework that contains classes that are written in Swift, all open to Objective-C using @objc annotations
  • Special configuration: this framework has a single Objective-C protocol (to maintain legacy compatibility), and all the other Swift classes implement this protocol. Umbrella header exports this protocol to public.
  • Library project loads this internal framework and refers to both Objective-C protocol and Swift classes
  • Main project loads library project via cocoapods, and also refers to the protocol and Swift classes in the internal frameworks

With this configuration, the library project compiles just fine, while the main project does not, emitting the following error when compiling Swift sources in the main project:

error: 'CLASS_NAME' is unavailable: cannot find Swift declaration for this class
    fileprivate var VARIABLE_NAME: [CLASS_NAME]
                                    ^~~~~~~~~~
__ObjC.CLASS_NAME:2:12: note: 'CLASS_NAME' has been explicitly marked unavailable here
open class CLASS_NAME : SUPER_CLASS_NAME {

It seems the module __ObjC refers to one that is auto-generated by Xcode, and maybe related to bridging header file, but the weird thing is that I didn't import any of sources from the internal framework on the bridging header.

I googled the error messages and it seems there are no similar issue. Is there a workaround for the error, or is this kind of settings somehow not available in Xcode? I know this is too complex for a single app project, but current situation is to touch the legacy codes as little as possible. Any help or suggestion will be appreciated. Thanks.

0 Answers
Related