Cannot Load Underlying Module for Xctest

Cannot load underlying module for XCTest

The main project does not link with the XCUnit framework. You should create a separate testing target for your project, if one does not already exist, and add your test source files to that target.

  1. Select your project in the Project Navigator. This will open the project's settings in the editor.
  2. Click the "+" button at the bottom of the column listing your Targets.

Sample Image


  1. If you are working on an iOS project template, select iOS > Test > iOS Unit Testing Bundle.

    If you are working on an OS X project template, select OS X > Test > OS X Unit Testing Bundle.

Cannot load underlying module for 'XCTest'

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'

Cannot load underlying module for unit tests

Finally, after examining each commit to see where it breaked, it turns out that the problem was probably coming from a unit test file I created, which had the same issue (probably didn't created it correctly), and then only removed its references instead of moving it to trash.

So I went a commit backward, used the default unit test file generated, and it worked.

Subclass XCTestCase results in cannot load underlying module XCTest

Under Framework Search Paths in Build Settings I have to add: $(PLATFORM_DIR)/Developer/Library/Frameworks

Then everything compiles fine :)

Cannot load underlying module for 'RealmSwift'

Firstly try to check what workspace you open after cocoapods were install open App.xcworkspace file.If yes open Pods directory and check if file is actually installed by manually navigation to REALM folder. After navigation to this article it is possible to conclude that you should:

New project -> build&run -> add realm via cocoapods -> open Xcode
workspace -> build&run again = success

Failed to load module 'project name'

Click on scheme -> Edit scheme -> select Test -> under info select Build configuration for which Enable testability is Yes. this solved my issue.



Related Topics



Leave a reply



Submit