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.
- Select your project in the Project Navigator. This will open the project's settings in the editor.
- Click the "+" button at the bottom of the column listing your Targets.
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
.
You've just added your tests file/class into main target and not into test target by mistake. Simple as that.
Solution:
1) Remove test file from "Compile Sources" list on "Build Phases" tab for main target
2) Add same file into "Compile Sources" on "Build Phases" tab for test target
It must resolve the issue