import swift class in objective-c, <myModule>-Swift.h file not found
OMG.. the actual import statement was not "class-Swift.h" but rather "projectname-Swift.h"
You can find the name of the file if you look under build settings->Swift Compiler Code Generation -> Objective-C Generated Interface Header Name
The file was not generated when I dragged in Swift source into the GUI. Only when I right-clicked->Add file to "project". It then asked to generate the header files.
In case anybody is wondering why after spending hours on this issue it is still unresolved, you might be in a situation similar to mine, where I was actually developing a framework, rather than an app.
In such case, the format of the import statement for Objective-C Generated Interface Header is as follows:
#import <ModuleName/ModuleName-Swift.h>
Updated May 2018 Xcode 9.3
- Build Settings->Objective-C Generated Interface Header Name
and set the value to YourModule-Swift.h (this is usually already set, this is the filename you need to import on .m file#import "YourModule-Swift.h"
(Example, Project named CData
)
Same as Step 1, Go to Build Settings and search for "Defines Module", set both values to YES
Create a class that extends
NSObject
on.swift
file
Build the project again
Import
YourModule-Swift.h
file on .m file (Please notice it's case sensitive,Mymodule
!==MyModule
)