Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"XXX-Swift.h" file not found in test project

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 Swift and 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?

like image 377
AppsDev Avatar asked Jul 22 '15 08:07

AppsDev


1 Answers

Go to Xcode Project > Build Settings and type "header name", you will get the below option:

enter image description here

Make sure that there must exist a file with a name: $(SWIFT_MODULE_NAME)-Swift.h

Then type, "bridging header" under Build Settings and make sure that the path of "bridging-header.h" file exist correctly.

enter image description here

Edited:

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

"$(TARGET_TEMP_DIR)/../$(PROJECT_NAME).build/DerivedSources"

For more, you can refer this link : iOS - 'MyProject-Swift.h' file not found when running Unit Tests for Swift

like image 108
Sohil R. Memon Avatar answered Sep 27 '22 01:09

Sohil R. Memon