saigafreak
saigafreak

Reputation: 415

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

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)'

Upvotes: 11

Views: 4439

Answers (7)

Binshad
Binshad

Reputation: 455

Select the specified file and check the Target Membership in the file inspector. You should select the correct target or module.

Upvotes: 0

Sergey
Sergey

Reputation: 79

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".

Upvotes: 3

Sebastian
Sebastian

Reputation: 497

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!

Upvotes: 1

Maximilian Litteral
Maximilian Litteral

Reputation: 3089

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

Upvotes: 9

Mario S.
Mario S.

Reputation: 9

I got the same issue when I added the AppNameTests folder and its files including Info.plist manually.

The solution was to delete all those manually created files. Afterwards go to AppName.xcodeproj, select General and add in TARGETS by clicking "+" a new Unit Testing Bundle. Then the folder AppNameTests (or however you named the folder) appears in the folder structure, including a test file and Info.plist. Since I couldn't access this new files I had to restart Xcode and then everything worked as expected.

Upvotes: 0

Jeevan Thandi
Jeevan Thandi

Reputation: 168

I was able to fix this by changing some build options in my test target

ENABLE_TESTING_SEARCH_PATHS = YES;
EXCLUDED_ARCHS = "x86_64-apple-ios-simulator";
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(EMBEDDED_CONTENT_CONTAINS_SWIFT)

Upvotes: -1

Cedric N
Cedric N

Reputation: 1

I assumed you are using xcode 12. You should try with xcode 11. And be sure to use ios target version 9.0 for your test. It worked for me.

Upvotes: -2

Related Questions