Unknown class in Compiled Swift Framework embedded in Objective-C Project

I have a framework binary built with Swift that I'm trying to incorporate into an Objective-C project. However the class in the framework isn't available.


In the swift framework, the class is defined like this:


@objcMembers
@objc public final class Messaging: NSObject, UINavigationControllerDelegate, LogsManagerDelegate {
    ...
}


I drag the archived and exported framework directly into the project to use and make sure the Defines Module is set to Yes in the Build Settings.


In the Objective-C I try to use the framework:


@import ContactAtOnceMessaging;

@implementation MessagingExperience
   Messaging *messaging;    // Unknown type name 'Messaging'
    ...

@end


If I drag the code for the framework directly into the project, Messaging is a known class so I know the Swift is okay.


I also tried changing the import to the following, but that didn't work.


#import "ContactAtOnceMessaging/ContactAtOnceMessaging-Swift.h"


What am I doing wrong?

PS: I also tried importing the framework using cocoapods and got the same results.

>> I drag the archived and exported framework directly into the project to use


Having a project item for the framework isn't enough. You have to tell Xcode that the app target links against the framework, and (assuming you want the framework to be incorporated into the app bundle) you have to tell Xcode to embed the framework.


You do these things by selecting the project item in the navigator, then selecting the app target, then in the General tab, add the framework to either the "Embedded Binaries" section or the "Linked Frameworks and Libraries" section.

Based on your reply, I verified this. When you drag the framework into the project, it does this automatically. So I'm still in the same spot.

Hmm, OK. The next thing I would try is to look inside the framework bunde ("Show Contents" in the Finder), and examine the public header files to see what the actual name of the class is. You can also try to figure this out using a partial auto-complete in Xcode, but it may suggest too many things to be reasonable.

Hi!

What did you do to solve the problem? I'm facing the exact same probleam with Xcode 11, I will apreciate some help

Hi!

What did you do to solve the problem? I'm facing the exact same probleam with Xcode 11.6, I will apreciate some help

Only not work simulator on objective c project.
Unknown class in Compiled Swift Framework embedded in Objective-C Project
 
 
Q