Importing Project-Swift.h into a Objective-C class…file not found

I was running into the same issue and couldn’t get my project to import swift into obj-c classes. Using Xcode 6, (should work for Xcode 6+) and was able to do it in this way….

  1. Any class that you need to access in the .h file needs to be a forward declaration like this

@class MySwiftClass;

  1. In the .m file ONLY, if the code is in the same project (module) then you need to import it with

#import "ProductModuleName-Swift.h"

Link to the apple documentation about it

https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_swift_into_objective-c

Leave a Comment