I think this occurred during a recent XCode update. I've tried cleaning and rebuilding but to no avail...
Failed to build module 'XCTest' from its module interface;
the compiler that produced it,
'Apple Swift version 5.3 (swiftlang-1200.2.26.4 clang-1200.0.29.4)',
may have used features that aren't supported by this compiler,
'Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)'
It can be done using Xcode, Go to Xcode->Preferences->Components-> Toolchains section and Select the Swift. 3.1. 1 snapshot, this will set the new Swift version for the local Xcode. You may need to restart Xcode.
You can also update every single Swift Package in your project at once. To do this, open the Files menu, navigate to Packages and then click Update to Latest Package Versions. Afterwards, make sure to test your project to see if everything still works, especially in projects with a lot of package dependencies.
XCTest, similarly to JUnit, invokes each test method on a separate instance of the test case. To illustrate with an example, imagine that you have ten test methods, the XCTest framework will instantiate ten instances of the test case class and invoke only one of the methods per instance.
However, XCTestCase ’s behavior isn’t that obvious which can make it counterintuitive when compared with how we're used to using objects to share state between methods.
To illustrate with an example, imagine that you have ten test methods, the XCTest framework will instantiate ten instances of the test case class and invoke only one of the methods per instance. We believe this is a good design choice, as by running the test methods in separate instances we can avoid sharing state between tests.
With Xcode 13 beta 4 (13A5201i), I am able to compile and run the project successfully while debugging on iPhone device but it gives below error. If you have a project that builds with Xcode 12.5.1 and fails to build with Xcode 13.0b4, you should report that as a bug against Xcode.
Tap on the file, open the inspector on the right, and make sure the file is included with the test target.
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With