xcode 无法为“XCTest”加载底层模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45129979/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot load underlying module for 'XCTest'
提问by me21
Every time I start to run my app, or I'm just starting Xcode I get this error:
每次我开始运行我的应用程序时,或者我刚刚启动 Xcode 时,我都会收到此错误:
I think the problem is that I don't know where my .xctest files are. I think I maybe deleted them.
我认为问题是我不知道我的 .xctest 文件在哪里。我想我可能删除了它们。
Would be very nice if someone of you could help me! Maybe tell me how to recover these files, make some new one or something else.
如果你们中有人能帮助我,那就太好了!也许告诉我如何恢复这些文件,制作一些新文件或其他东西。
回答by Paul Solt
You accidentally added one of your Xcode Unit Test files to your main app target.
您不小心将 Xcode 单元测试文件之一添加到您的主应用程序目标。
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.
提示:下次添加新单元测试时,只需将其添加到单元测试目标中。如果您不小心包含了任何应用程序目标,它们将无法使用 XCTest 框架。
回答by Will Loew-Blosser
See also Apple Technical Q&A QA1954 'Cannot load underlying module for XCTest' which covers several variants of the issue
另请参阅 Apple 技术问答 QA1954“无法为 XCTest 加载底层模块”,其中涵盖了该问题的多个变体
https://developer.apple.com/library/archive/qa/qa1954/_index.html
https://developer.apple.com/library/archive/qa/qa1954/_index.html
回答by sunil chayagol
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.
主项目不与 XCUnit 框架链接。您应该为您的项目创建一个单独的测试目标(如果尚不存在),并将您的测试源文件添加到该目标。
Select your project in the Project Navigator. This will open the project's settings in the editor. Click the "+" button at the bottom of the column listing your Targets. If you are working on an iOS project template, select iOS > Test > iOS Unit Testing Bundle.
在项目导航器中选择您的项目。这将在编辑器中打开项目的设置。单击列出目标的列底部的“+”按钮。如果您正在处理 iOS 项目模板,请选择 iOS > 测试 > iOS 单元测试包。
If you are working on an OS X project template, select OS X > Test > OS X Unit Testing Bundle.
如果您正在处理 OS X 项目模板,请选择 OS X > 测试 > OS X 单元测试包。