我正在使用Xcode 6.4和iOS 8.4使用此命令在Circle CI上运行iOS测试:
xctool -workspace ios.xcworkspace -scheme ios test -sdk iphonesimulator8.4
但是当模拟器运行时,它无法运行我的测试并收到此错误:
测试没有运行:模拟器无法启动,或者TEST_HOST 应用程序无法运行。模拟器错误:遇到异常 连接到CoreSimulatorBridge:无法连接到 CoreSimulatorBridge
查看日志,看起来模拟器实际上试图针对iOS 9运行:
run-test iosTests.xctest(iphonesimulator9.0,iPhone 4s,应用程序测试)
有没有办法强制它在iOS 8.4上运行,所以测试会运行?
答案 0 :(得分:2)
我最近在Circle CI上遇到了同样的问题。我不确定它是否与xctool的最新版本(0.2.7)有关,但添加此内容为我修复了它:
(function(){
var attachEvent = document.attachEvent;
var isIE = navigator.userAgent.match(/Trident/);
console.log(isIE);
var requestFrame = (function(){
var raf = window.requestAnimationFrame || indow.mozRequestAnimationFrame
|| window.webkitRequestAnimationFrame
|| function(fn){ return window.setTimeout(fn, 20); };
return function(fn){ return raf(fn); };
})();
var cancelFrame = (function(){
var cancel = window.cancelAnimationFrame
|| window.mozCancelAnimationFrame
|| window.webkitCancelAnimationFrame
|| window.clearTimeout;
return function(id){ return cancel(id); };
})();
function resizeListener(e){
var win = e.target || e.srcElement;
if (win.__resizeRAF__) cancelFrame(win.__resizeRAF__);
win.__resizeRAF__ = requestFrame(function(){
var trigger = win.__resizeTrigger__;
trigger.__resizeListeners__.forEach(function(fn){
fn.call(trigger, e);
});
});
}
function objectLoad(e){
this.contentDocument.defaultView.__resizeTrigger__ = this.__resizeElement__;
this.contentDocument.defaultView.addEventListener('resize', resizeListener);
}
window.addResizeListener = function(element, fn){
if (!element.__resizeListeners__) {
element.__resizeListeners__ = [];
if (attachEvent) {
element.__resizeTrigger__ = element;
element.attachEvent('onresize', resizeListener);
}
else {
if (getComputedStyle(element).position == 'static')
element.style.position = 'relative';
var obj = element.__resizeTrigger__
= document.createElement('object');
obj.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
obj.__resizeElement__ = element;
obj.onload = objectLoad;
obj.type = 'text/html';
if (isIE) element.appendChild(obj);
obj.data = 'about:blank';
if (!isIE) element.appendChild(obj);
}
}
element.__resizeListeners__.push(fn);
};
window.removeResizeListener = function(element, fn){
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
if (!element.__resizeListeners__.length) {
if (attachEvent) element.detachEvent('onresize', resizeListener);
else {
element.__resizeTrigger__.contentDocument.defaultView.removeEventListener('resize', resizeListener);
element.__resizeTrigger__ = !element.removeChild(element.__resizeTrigger__);
}
}
}
})();
所以你的案例中的完整命令应该是:
-destination platform='iOS Simulator,OS=8.4,name=iPhone 6'