Cannot load underlying module for XCTest
You accidentally added one of your Xcode Unit Test files to your main app target.
Remove it:
- Select test file
- Open right side panel
- Select Identity and Type tab
- Unselect your app Target (not the unit test lego icon)
Tip: Next time you add a new unit test, only add it to your unit test target. If you accidentally include any of your app targets, they will not have the XCTest framework available.
See also Apple Technical Q&A QA1954 'Cannot load underlying module for XCTest' which covers several variants of the issue
https://developer.apple.com/library/archive/qa/qa1954/_index.html