Xcode 6在物理iOS设备上运行测试不起作用

Leg*_*ess 6 iphone xcode unit-testing ios ios8

我在物理设备上运行单元测试目标时遇到问题(在我的情况下,带有iOS 8.1的iPhone 6).为此,我创建了一个全新的iOS Xcode项目,打开它并使用Cmd + U(产品 - >测试)运行测试.该应用程序成功编译并询问我的代码签名凭据.该应用程序甚至在设备上打开了.一切都很好,直到这一部分.

但测试永远不会运行,Xcode会在"测试"中停留几分钟,然后最终退出:

*** Canceling tests due to timeout in Waiting for test process to check in...
Run Code Online (Sandbox Code Playgroud)

控制台抛出一些代码签名错误或类似错误:

2014-10-30 08:54:12.585 Test[4721:1298810] Error loading /private/var/mobile/Containers/Data/Application/B727E18E-48BC-4A7E-BDBA-19157ED5A4AC/tmp/TestTests.xctest/TestTests: 

dlopen(/private/var/mobile/Containers/Data/Application/B727E18E-48BC-4A7E-BDBA-19157ED5A4AC/tmp/TestTests.xctest/TestTests, 262): no suitable image found.
Did find: /private/var/mobile/Containers/Data/Application/B727E18E-48BC-4A7E-BDBA-19157ED5A4AC/tmp/TestTests.xctest/TestTests: 

code signature invalid for '/private/var/mobile/Containers/Data/Application/B727E18E-48BC-4A7E-BDBA-19157ED5A4AC/tmp/TestTests.xctest/TestTests'
DevToolsBundleInjection: Error loading bundle '/private/var/mobile/Containers/Data/Application/B727E18E-48BC-4A7E-BDBA-19157ED5A4AC/tmp/TestTests.xctest'
Run Code Online (Sandbox Code Playgroud)

我真的没有得到它,应用程序正确签名,但我猜测注入的测试库不是.

任何人都知道如何解决这个问题?或者这是否意味着我们仅限于在模拟器中进行测试?

我一直在测试它的项目可以在我的GitHub上找到:https://github.com/Legoless/StackOverflow/tree/master/Objective-C/TestTargetFailure

谢谢.

小智 2

这是一个代码签名问题。

解决方案:转到测试目标的构建设置,并确保设置了正确的(即与测试目标的捆绑包 ID 匹配)配置文件和代码签名身份。您可以为此生成通配符配置文件。