Unit tests cannot find project header files, all other targets can

All targets can see all my header files in the project if I just import them with #import "header.h", except my unit tests.

When editing the unit test the editor says file not found and marks the line in red.

However, when running the unit tests, it compiles, it runs, and it succeeds, which would be impossible if the header wasn't found. So the header is found when building the test but it isn't found when editing the test. How can I fix that?

Explicitly listing all directories with header files as User Header Search Paths solves the problem, but why do I have to do that? I don't have to do that with other targets and apparently Xcode can find the header on its own when building the unit tests.

It seems like Xcode is not using header map files when editing unit tests, only when building them. Yet it uses header map files everywhere else in the project and according to build settings it should use them for unit tests, too (settings have the same values as for all other targets).

I'm using Xcode 12 and the same issue exists in Xcode 12.2 Beta 2.
If there was at least a way to see with what build settings unit tests are built in the editor. I can only see it, when running tests but when running tests, everything is okay and builds fine. The errors are only there when editing unit test files.

I added a headers phase to the build phases of the unit test target and added the not found headers there, even as public headers but the editor still cannot find them, unless their directories are listed under USER_HEADER_SEARCH_PATHS or unless I add the test files to the main target of the project, where they definitely don't belong.

The header files don't belong to the main target, the belong to a framework target that is built along with the main target and then added to the main targets bundle and they are project headers to the framework but that usually plays no role anywhere else in the project. The project has over a dozen targets and in every file from every target this header can just be included with #import "header.h", it will work in the editor and it will work when building. It only fails for unit test targets.

And yes, there are multiple unit test targets but the other ones either just test a frameworks public functionality (so they don't import headers at all, they import the framework as a whole with @import framework;, which is not possible in that case) or they require no headers as they test Swift code. I tried whether that import would work in any other test target and it fails the same, so this is nothing specific to the test target either.
I also discovered it won't just affect headers. When I want to use code from frameworks in the unit test and do a @import framework, I get error "Module framework not found` in the editor. Despite the fact that the framework is listed under "Link Binary With Libraries" and even as explicitly under "Dependencies". Again, it is built correctly when running the tests and it can be used correctly when running the tests, just the editor fails to find them. I also have no autocompletion for any symbols in the frameworks or headers.
I have statically linked OpenSSL to my MacOS project, listing OpenSSL under Library search paths and Header Search Paths.

Whenever I try to run unit tests, I get 'openssl/conf.h' file not found`
Is there any solution for this?
Unit tests cannot find project header files, all other targets can
 
 
Q