James James - 1 year ago 145
Swift Question

Import Swift Framework in Objective-C Project - Error - Unknown Type Name

I've been wrestling with this specific issue for a while now. Basically I've added a framework BigNerdRanch CoreDataStack using Carthage.

But I've been having issues of using the said framework on my Objective-C codes. My project is an Objective-C project in which I recently added Swift codes and Swift frameworks.

So far I've been able to use Swift frameworks in my Swift codes with no problems. But once I started using the said Swift frameworks on my old Obj-C, specifically AppDelegate.m, I keep getting compiler error no matter what.

From what I understand I have to import it like this:

#import <CoreDataStack/CoreDataStack-Swift.h>

In which I did on AppDelegate.m.

I also have the following setup on my project:

Project Target Setup:

enter image description here

Build Settings for Swift Compilation:

enter image description here

I've been seeing some answers in StackOverflow to add public to the classes. But I'm unable to do so since the imported Frameworks are self-contained and only contains Headers for me to see in the XCode project.

enter image description here

Thanks for the help guys.

Answer Source

You added a framework written in swift, if they don't enable support for Objective C, you can't use it in your objective c code.

However, you can create a class in swift, which will be used as a mediator between the framework and your ObjC classes.

@objc class coreDataStackConvertor: NSObject {

    func createStack(arg: Type) {

        // Code which uses the real CoreDataStack


From you objective c classes, you can use the methods in the convertor class.