Build succeeds but errors highlighted in the editor

I am using xcode 8, in a project where I mix objective c and swift 3.


In my objective C file, if I include the Objective C Generated Interface Header (MODULENAME-Swift) to use my swift classes. Even though the project compiles properly and the program runs fine, when I open the object C file including the -swift.h header, errors are reported in the source code. The error do not make sense: it complains about "ambiguous reference", and the two candidates it mentions are excalty the same file.


This only happens in my full blown project, I have not been able to reproduce in a smaller test project.


I have tried multiple clean and delete of the derived data. If I build the project and the file with the issues are not opened, it's all good. As soon as I select the file with the Swift header include, the error appears.


It seems xcode must run some compile in the background independent of the main build process and this gets confused. But I couldn't figure out how to fix it or configure it properly.


Any idea?

We have similar issue happen in Xcode 14.2, we have to clean build folder several time and build again to get it run. Sometime we can run the app in simulator even we have compile error. I think it is Xcode bug, can any Xcode developer in Apple give us the answer for this issue?

Same here in Xcode 14.2: Xcode starts to show the error "cannot find XCUIApplication in scope" in UI test files, even though the tests can build and succeed.

Clearing build folder (cmd + shift + k), quitting Xcode (cmd + q), restarting Xcode, and finally clearing folder again helps. Very disturbing to workflow though.

I am facing a similar issue. In my case, it's even worse. The error shows even if i don't open the objective-c file.

Build succeeds but errors highlighted in the editor
 
 
Q