在终端上运行的 GHUnit 脚本显示“可执行文件中的 CPU 类型错误”。它通过 XCode 在设备和模拟器上执行,但在终端上显示 CPU 错误。
引用:http://gabriel.github.io/gh-unit/docs/appledoc_include/guide_command_line.html 尝试重置设备网络设置
使用 Xcode5、iOS7 和 Wifi 网络
还有其他可能性通过命令行运行 ghunit 测试脚本吗?
最佳答案
确保您使用的是模拟器而不是真实设备,并且有效架构还包括 i386。
来 self 的 blog
我找到了一个很好的解决方法,适用于我的模拟器。 只需更改 main.m:
#import <UIKit/UIKit.h>
#import <GHUnitIOS/GHUnitIOSViewController.h>
int main(int argc, char *argv[])
{
int retVal;
@autoreleasepool {
if (getenv("GHUNIT_CLI")) {
retVal = [GHTestRunner run];
} else {
retVal = UIApplicationMain(argc, argv, nil, @"GHUnitIOSAppDelegate");
}
}
return retVal;
}
已编辑:我成功地从命令行在设备上运行,步骤如下:
来 self 的 blog
使用工具 ideviceinstaller安装到您的设备中
ideviceinstaller -i <your app>.ipa
获取设备中的应用程序文件夹(以保留 xml 文件)
app_path=
ideviceinstaller -l -o xml | grep <your app>.app | sed 's/.*<string>\(.*\)<your app>.app<\/string>/\1/'
将测试应用程序运行到设备中(不要保存在 tmp 文件夹中,tmp 文件夹在存档时会被删除)并将 XML 保存到“Caches”文件夹中。 (使用 idevice-app-runnner 工具)
idevice-app-runner -s com.<org>.<your scheme> -DGHUNIT_CLI=YES -DGHUNIT_AUTORUN=YES -DGHUNIT_AUTOEXIT=YES -DWRITE_JUNIT_XML=YES -DJUNIT_XML_DIR=$app_path/Library/Caches/test-results
从设备获取存档应用程序(以提取 xml 文件)- 测试应用程序完成运行后
ideviceinstaller -a com.<org>.<your scheme> -o copy=. -o remove
mv com.<org>.<your app>.ipa <any app name>.zip
unzip -o <any app name>.zip
cp Container/Library/Caches/test-results/*.* <your folder to keep the result xml files>
关于ios - GHUnit - 终端 - "BAD CPU type in executable",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20263007/