Using Swift classes from Objective-C code
suggest changeIn the same module
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:
public
#import "MyApp-Swift.h"
#import <MyFramework/MyFramework-Swift.h>
Relevant build settings:
- Objective-C Generated Interface Header Name: controls the name of the generated Obj-C header.
- Install Objective-C Compatibility Header: whether the -Swift.h header should be a public header (for framework targets).
In another module
Using @import MyFramework;
imports the whole module, including Obj-C interfaces to Swift classes (if the aforementioned build setting is enabled).
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents