I'm trying to call a method of a
NSObject subclass I have in the let's say "main" project within a method of a
XCTestCase subclass in the test project. The
NSObject subclass of the main project imports the "XXX-Swift.h" header file (I'm mixing
Objective-C code). All works fine when I run the main project, but when I run the tests calling an object of that subclass, I get an error saying that the
Swift header file in the import is not found.
I guess I'm missing some settings in the test target, but I don`t find which... what should I check? Or what should I do to solve this?
Go to Xcode Project > Build Settings and type "header name", you will get the below option:
Make sure that there must exist a file with a name:
Then type, "bridging header" under Build Settings and make sure that the path of "bridging-header.h" file exist correctly.
1) Make sure that your "Project Name" doesn't contains spaces 2) Well "XXX-Swift.h" file is generated at the following path, so you need to add that path to unit test - Go to build settings, type "Header Search Paths" and add the following line
For more, you can refer this link : iOS - 'MyProject-Swift.h' file not found when running Unit Tests for Swift