A couple of days ago Xcode stopped loading our tests into the test navigator. Additionally our test class files stopped showing the gutter test diamonds. We can still run the tests using CMD+U and after a successful run every test case shows up in the test navigator. But, the test diamonds don't return which implies that Xcode doesn't see these files as tests.
So, it seems that something in our project has broken Xcode's test case indexing.
The project is mainly Obj-C with an growing Swift part. Our test suite contains ~6000 unit tests derived from XCTestCase. This problem is reproducible on El Capitan 10.11.3, both when using Xcode 7.2.1 and Xcode 7.3 beta 5.
We've tried all the usual measures for when dealing with bad Xcode state:
- Clean building.
- Deleting derived data.
- Deleting ~/Library/Caches/com.apple.dt.XCode
Is this a known issue? Can anyone help us understand how Xcode discovers the tests so that we could fix the issue with our project?
Update:
When observing what happens in Console.app when opening Xcode we see the following lines:
17/03/16 11:44:44,717 Xcode[89856]: IDEIndexingClangInvocation: Failed to save PCH file: /Users/johannth/Library/Developer/Xcode/DerivedData/MyApp-fmkkuqtykhsstrezzmhrfiedrpcu/Index/PrecompiledHeaders/UnitTests-Prefix-dvmyiewguqjpnbflmvoybdjdec.pch.pch
17/03/16 11:44:53,954 sourcekit-serv[89989]: [1:hashFileReference:8599: 2.1299] failed to stat file: <imports> (No such file or directory)
We actually see a lot of the latter error. By running git bisect we've pinpointed that setting `DEFINE_MODULE=YES` introduced the issue and reverting it to `DEFINE_MODULE=NO` fixes it with various weird side effects. The .pch file for UnitTests only contains the standard Foundation and UIKit imports so I don't think there is anything directly in it which breaks the indexing.
Anyone have any idea how to better understand the console logs from Xcode?