Solved - Swift XCTest Cannot Find in ScopeMon Apr 05 2021
When creating Swift tests in XCTest
, the files being tested need to have Target Membership
in the test target. If the test file throw an error Cannot find _ in scope
, the solution is to add the file you intend to test to the test target.
- Open the file you intend to test.
- On the Right Panel click the paper page
- In
Target Membership
select your test target - Product > Clean
- Build
For a guide on how to set up testing on a swift project read iOS Unit Testing and UI Testing Tutorial.