xcodemacosunit-testingnsworkspacexctestplan

XCode Unit Tests - Cannot find viewcontroller in scope


At some point in my app's development, my Unit Tests and UI Tests lost access to my app's main module:

🛑 Cannot find type 'FileVacuumViewController' in scope

Cannot find type 'FileVacuumViewController' in scope

They worked with the xctestplan before. I don't know at what point it happened. I tried not importing @testable, including the tests.swift in the main module's "Target Membership".

Maybe I need to open the workspace instead of the xcproject? When I try to open the workspace there was an error message and no files show in the tree: enter image description here


Here's my xctestplan config:

xctestplan config

When I clicked to run one the UI tests individually, about 20 of these code sign dialogs showed:

code sign popups


Solution

  • Looks like your test file is included in both your app target and test bundle. Make sure to uncheck it from app target and try clean & build.