如何设置默认设备以在 Ionic 中模拟?
How can I set the default device to emulate in Ionic?
我正在使用 Ionic 构建一个 iOS 应用程序。现在我正在测试它在 iPad 2 中的表现,但这样做需要我不断地写:
ionic emulate ios --target="iPad-2"
有没有办法在 ionic.project 文件或其他地方的某处进行硬编码,这样我就可以停止手动执行此操作?谢谢
我遇到了同样的问题,尽管这个问题已有一年之久,但这是我通过 google 得到的第一件事,并且在其他任何地方都找不到答案。这是我所做的只是因为我不想每次都使用--target="iPhone-7"。
对于那些只想在特定 ios 设备上 运行 的人来说,请使用以下命令:
ionic run ios --target="iXXX-X"
iXXX-X 将是您从 运行ning 获得的名称之一
ios-sim showdevicetypes
例如:
ionic run ios --target="iPhone-7"
我想有一个解决方案使 iPhone-7 成为我的默认值,所以 运行 以下内容将以 iPhone-7 为目标(我原来的默认目标是 iPhone-SE):
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);
}
}
我正在使用 Ionic 构建一个 iOS 应用程序。现在我正在测试它在 iPad 2 中的表现,但这样做需要我不断地写:
ionic emulate ios --target="iPad-2"
有没有办法在 ionic.project 文件或其他地方的某处进行硬编码,这样我就可以停止手动执行此操作?谢谢
我遇到了同样的问题,尽管这个问题已有一年之久,但这是我通过 google 得到的第一件事,并且在其他任何地方都找不到答案。这是我所做的只是因为我不想每次都使用--target="iPhone-7"。
对于那些只想在特定 ios 设备上 运行 的人来说,请使用以下命令:
ionic run ios --target="iXXX-X"
iXXX-X 将是您从 运行ning 获得的名称之一
ios-sim showdevicetypes
例如:
ionic run ios --target="iPhone-7"
我想有一个解决方案使 iPhone-7 成为我的默认值,所以 运行 以下内容将以 iPhone-7 为目标(我原来的默认目标是 iPhone-SE):
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);
}
}