import swift class in objective-c, -Swift.h file not found

Updated May 2018 Xcode 9.3


  1. 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)

Example

  1. Same as Step 1, Go to Build Settings and search for “Defines Module”, set both values to YES

  2. Create a class that extends NSObject on .swift file

Example

  1. Build the project again

  2. Import YourModule-Swift.h file on .m file (Please notice it’s case sensitive, Mymodule !== MyModule)

enter image description here

Leave a Comment