Brduca Brduca - 2 months ago 199x
Swift Question

Cannot load underlying module for XCTest

I'm working in swift on xcode and by default it creates a test file that references XCTest.

When I set the target membership to my main project it causes this error
"Cannot load underlying module for XCTest".

If this target membership is not set the tests runs properly and everything works fine.

PS: I'm new to swift and it's probably a dumb question (please enlighten me)

pwc pwc

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.
  3. If you are working on an iOS project template, select iOS > Other > Cocoa Touch Testing Bundle.

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