我正在使用Ionic构建一个iOS应用程序。现在,我正在测试它在iPad 2中的行为,但要做到这一点,我需要不断地编写:
ionic emulate ios --target="iPad-2"有没有一种方法可以在ionic.project文件中或其他地方对此进行硬编码,这样我就可以停止手工操作了吗?谢谢
发布于 2017-05-10 07:17:58
我经历了同样的问题,尽管这个问题已经存在了一年,但这是我第一次在谷歌上找到答案,在其他地方也找不到答案。我之所以这么做是因为我不想每次都使用--target="iPhone-7“。
要让任何想要在特定ios设备上运行的人明白这一点,请使用以下方法:
ionic run ios --target="iXXX-X"例如,iXXX-X将是运行ios-sim showdevicetypes时获得的名称之一:
ionic run ios --target="iPhone-7"我希望有一个解决方案,使iPhone-7成为我的默认设置,因此运行以下程序将针对iPhone-7 (我最初的默认目标是iPhone):
ionic run ios看起来默认值是硬编码的,因此必须在代码中进行更改。我找到了这个文件: /platforms/ios/cordova/lib/run.js
在这里您可以找到一个名为deployToSim的函数,我对它做了如下修改:
function deployToSim(appPath, target) {
// Select target device for emulator. Default is 'iPhone-6'
if (!target) {
return require('./list-emulator-images').run()
.then(function(emulators) {
if (emulators.length > 0) {
target = emulators[0];
}
emulators.forEach(function(emulator) {
// this is the original condition
// if (emulator.indexOf('iPhone') === 0)
// change "iPhone" to the specific model you want, in my case it's iPhone-7
// Notice the comma in iPhone7, without comma it will take iPhone-7-plus instead
if (emulator.indexOf('iPhone-7,') === 0) {
target = emulator;
}
});
events.emit('log', 'No target specified for emulator. Deploying to ' + target + ' simulator');
return startSim(appPath, target);
});
} else {
return startSim(appPath, target);
}
}
https://stackoverflow.com/questions/35296187
复制相似问题