Inside a module named "MyModule", Xcode generates a header named MyModule-Swift.h
which exposes public Swift classes to Objective-C. Import this header in order to use the Swift classes:
// MySwiftClass.swift in MyApp
import Foundation
// The class must be `public` to be visible, unless this target also has a bridging header
public class MySwiftClass: NSObject {
// ...
}
// MyViewController.m in MyApp
#import "MyViewController.h"
#import "MyApp-Swift.h" // import the generated interface
#import <MyFramework/MyFramework-Swift.h> // or use angle brackets for a framework target
@implementation MyViewController
- (void)demo {
[[MySwiftClass alloc] init]; // use the Swift class
}
@end
Relevant build settings:
Using @import MyFramework;
imports the whole module, including Obj-C interfaces to Swift classes (if the aforementioned build setting is enabled).