Failed to build module XCTest due to some Swift versionitis issue?

Solution 1:

Tap on the file, open the inspector on the right, and make sure the file is included with the test target.

Solution 2:

Looks like you have created the test case class as a usual Swift file (File->New->Swift File). I have solved the issue with creating a test class via File->New->Unit Test Case Class".

Solution 3:

This morning I ran into the same error when I created a new unit test file. The file was created somewhere in the project navigation tree - maybe next to the struct I wanted to test. I deleted it.

This evening I tried it again but created the unit test file via File -> New -> ... from within the Tests folder - now it works!