Reputation: 3878
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
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:
Here's my xctestplan config:
When I clicked to run one the UI tests individually, about 20 of these code sign dialogs showed:
Upvotes: 17
Views: 22032
Reputation: 3342
I just ran into this issue myself after upgrading to Xcode 13.
The solution for me was to remove the file from both XCTest AND XCUITest Target dependencies:
Project Settings -> <Target>Tests -> Build Phases -> select file and click "-"
Project Settings -> <Target>UITests -> Build Phases -> select file and click "-"
Now try to run your test and add @testable import <Target>
to the top of your XCTest files that error out. NOTE: you should not have to add this at all to your UITests files at all.
Upvotes: 0
Reputation: 1819
I ran into this recently with XCode 13 while following a blog post on creating unit tests. For some reason, XCode didn't automatically add the ViewController to the Test target.
My solution was to make sure that the ViewController was included in the Target Membership for the test suite. I had to also make the same Target Membership change for the Main storyboard.
Upvotes: 12
Reputation: 595
Select file "FileVacuumViewController" in Project Navigator and, in File Inspector, in the section Target Membership, check field which ends with Tests and UITests. Clean and build project, if necessary.
Upvotes: 1
Reputation: 5113
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.
Upvotes: 27