xcode XCTest:无法加载包“目标测试”,因为无法找到其可执行文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29662266/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:00:23  来源:igfitidea点击:

XCTest: The bundle “target Tests” couldn’t be loaded because its executable couldn’t be located

iosobjective-cxcodexctest

提问by jcardenete

I'm using XCode 6.2 and I have a project with several targets and with no tests.

我正在使用 XCode 6.2 并且我有一个包含多个目标且没有测试的项目。

I'm trying to include now XCTest for one of the targets. To do so, I add a new "Cocoa Touch Testing Bundle" and select the target that I want as a host.

我现在正在尝试为目标之一包含 XCTest。为此,我添加了一个新的“Cocoa Touch Testing Bundle”并选择我想要的目标作为主机。

When trying to launch the test with Cmd+U, the simulator launches, opens the app for some milliseconds and then it closes, launching this message:

当尝试使用 Cmd+U 启动测试时,模拟器启动,打开应用程序几毫秒,然后关闭,启动此消息:

IDEBundleInjection.c: Error 4 loading bundle '/Users/pepito/Library/Developer/Xcode/DerivedData/Flight-gpauuftblwwxtvevnylzllkypkjy/Build/Products/Debug-iphonesimulator/target Tests.xctest': The bundle “target Tests” couldn't be loaded because its executable couldn't be located.

IDEBundleInjection.c:错误 4 加载包'/Users/pepito/Library/Developer/Xcode/DerivedData/Flight-gpauftblwwxtvevnylzllkypkjy/Build/Products/Debug-iphonesimulator/target Tests.xctest':包“目标测试”不能已加载,因为无法找到其可执行文件。

When I check the folder specified there, there is a just the Info.plist file, but there is no executable.

当我检查那里指定的文件夹时,只有 Info.plist 文件,但没有可执行文件。

I have tried adding a branch new app target, which added automatically tests for it. The same error happens there when trying to run the tests.

我尝试添加一个分支新应用程序目标,它为它添加了自动测试。尝试运行测试时会发生同样的错误。

If I create tests for a target in a brand new XCode project, then it works fine.

如果我在一个全新的 XCode 项目中为目标创建测试,那么它工作正常。

采纳答案by jcardenete

I finally managed to solve the problem. It was related to the compiler selected by default for the XCTest target. It had selected "Unsupported Compiler" and I changed to "Default compiler (Apple LLVM 6.1)" and it started working again.enter image description here

我终于设法解决了这个问题。它与默认为 XCTest 目标选择的编译器有关。它选择了“不支持的编译器”,我改为“默认编译器(Apple LLVM 6.1)”,然后它又开始工作了。enter image description here

回答by icecrystal23

I got this error today because I forgot to add sources to the "Compile Sources" build phase in my test target.

我今天收到此错误,因为我忘记将源添加到测试目标中的“编译源”构建阶段。

回答by Mert Buran

In my case, target's iOS Deployment Targetin Build Settingswas lower than target device's version. Hope that helps someone.

在我的情况下,目标公司iOS Deployment TargetBuild Settings比目标设备的版本低。希望能帮助某人。