I am creating Swift framework in which I have to use Objective-C class. So I went through this link. This is the public header of my framework :
#import <UIKit/UIKit.h>
//! Project version number for Test.
FOUNDATION_EXPORT double TestVersionNumber;
//! Project version string for Test.
FOUNDATION_EXPORT const unsigned char TestVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Test/PublicHeader.h>
#import <arpa/inet.h>
#import <ifaddrs.h>
#import <netdb.h>
#import <sys/socket.h>
#import <MyTest/MPAppDelegateProxy.h>
Now in class MPAppDelegateProxy, I have to use a Swift
class which I have created. This is :
#import "MPAppDelegateProxy.h"
#import "MyTest.h"
@implementation MPAppDelegateProxy
+ (void)proxyAppDelegate {
[MPGlobal MPLog:@"App delegate not set, unable to perform automatic setup." file:@"MPAppDelegateProxy.m" function:@"proxyAppDelegate" line:32];
// rest of code
}
MPGlobal is one of my Swift
class. But I am getting :
Use of undeclared identifier 'MPGlobal'
Note : I have added @objC
before MPGlobal.
You need to import
<Target>-Swift.h
file. This is known as Objective-C Generated Interface Header Name.You can find it in your Target's build settings.
This file is auto generated by compiler and it needs to be imported in Objective-C files.