Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot load underlying module for 'XCTest'

Tags:

xcode

ios

swift

Every time I start to run my app, or I'm just starting Xcode I get this error:

This is the error.

I think the problem is that I don't know where my .xctest files are. I think I maybe deleted them.

Would be very nice if someone of you could help me! Maybe tell me how to recover these files, make some new one or something else.

like image 823
me21 Avatar asked Jul 16 '17 14:07

me21


People also ask

How do I run XCTest in Xcode?

To run your app's XCTests on Test Lab devices, build it for testing on a Generic iOS Device: From the device dropdown at the top of your Xcode workspace window, select Generic iOS Device. In the macOS menu bar, select Product > Build For > Testing.

What is XCTest in Xcode?

Use the XCTest framework to write unit tests for your Xcode projects that integrate seamlessly with Xcode's testing workflow. Tests assert that certain conditions are satisfied during code execution, and record test failures (with optional messages) if those conditions aren't satisfied.

Where is XCTest?

xctest can be found inside of the . app file, so in order to locate it, right-click the app and select Show in Finder. Right-click the app again in Finder and select Show Package Contents.

What is XCTest bundle?

An XCTest bundle is a CFBundle with a special product-type and bundle extension. The Mac Developer Library provides more information in the Testing with Xcode document.


1 Answers

You accidentally added one of your Xcode Unit Test files to your main app target.

Remove it:

  1. Select test file
  2. Open right side panel
  3. Select Identity and Type tab
  4. Unselect your app Target (not the unit test lego icon)

Tip: Next time you add a new unit test, only add it to your unit test target. If you accidentally include any of your app targets, they will not have the XCTest framework available.

Fix Cannot load underlying module for 'XCTest'

like image 70
Paul Solt Avatar answered Sep 23 '22 09:09

Paul Solt