importing swift framework into a objective-c project

Michael A picture Michael A · Jun 28, 2015 · Viewed 32.5k times · Source

I am importing swift framework into objective-c project like this:

@import MyFramework;

The problem is that only some of the classes are recognized by the class i am importing the framework.

The class which is recognized:

public class RecognizedClass:UIViewController, WKNavigationDelegate, WKScriptMessageHandle 
 { ... } 

The class which is not:

public class VeediUtils
{ ... } 

They are both public so why the first is recognized in the workspace and the other not?

Also i see in the header file MyFramework-Swift.h that a class

@interface RecognizedClass : UIViewController <WKNavigationDelegate, WKScriptMessageHandler>

Appear while the other dont

Why is that?

Also to point that this same procedure work when i am importing swift framework to swift project

Answer

saltwat5r picture saltwat5r · Apr 19, 2016

If you previously configured Project for integrating with Swift and want to use Swift Dynamic Framework, you have to import it like this way (replace {value} with appropriate names depending on your Project):

#import <{MyFramework}/{MyFrameworkMainClass}-Swift.h>  
#import "{YourProjectTargetName}-Swift.h"

EDIT:

If your framework has Defines Module set to true, then you can import it like this:

@import MyFramework;