Skip to content

Commit 32a7b12

Browse files
committed
[TIMOB-19411] Fixed findSimulators() to take into account the min iOS version.
1 parent 3c2aad2 commit 32a7b12

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/simulator.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,11 @@ function findSimulators(options, callback) {
510510
// no watch sim, just an ios sim
511511
// find the version of Xcode
512512
Object.keys(simHandle.supportsXcode).sort().reverse().forEach(function (id) {
513-
if (simHandle.supportsXcode[id] && xcodeInfo.xcode[id].supported && (!options.iosVersion || xcodeInfo.xcode[id].sdks.indexOf(options.iosVersion) !== -1)) {
513+
if (simHandle.supportsXcode[id] &&
514+
xcodeInfo.xcode[id].supported &&
515+
(!options.iosVersion || xcodeInfo.xcode[id].sdks.indexOf(options.iosVersion) !== -1) &&
516+
(!options.minIosVersion || xcodeInfo.xcode[id].sdks.some(function (ver) { return appc.version.gte(ver, options.minIosVersion); }))
517+
) {
514518
selectedXcode = xcodeInfo.xcode[id];
515519
return true;
516520
}
@@ -520,6 +524,8 @@ function findSimulators(options, callback) {
520524
if (!selectedXcode) {
521525
if (options.iosVersion) {
522526
return callback(new Error(__('Unable to find any Xcode installations that support both iOS %s and iOS Simulator %s.', options.iosVersion, options.simHandleOrUDID)));
527+
} else if (options.minIosVersion) {
528+
return callback(new Error(__('Unable to find any Xcode installations that support at least iOS %s and iOS Simulator %s.', options.minIosVersion, options.simHandleOrUDID)));
523529
} else {
524530
return callback(new Error(__('Unable to find any supported Xcode installations. Please install the latest Xcode.')));
525531
}
@@ -578,6 +584,9 @@ function findSimulators(options, callback) {
578584
if (options.iosVersion && xcodeInfo.xcode[ver].sdks.indexOf(options.iosVersion) === -1) {
579585
return false;
580586
}
587+
if (options.minIosVersion && !xcodeInfo.xcode[ver].sdks.some(function (ver) { return appc.version.gte(ver, options.minIosVersion); })) {
588+
return false;
589+
}
581590
return true;
582591
})
583592
.sort(function (a, b) { return !xcodeInfo.xcode[a].selected || a > b; });
@@ -638,6 +647,8 @@ function findSimulators(options, callback) {
638647
if (!selectedXcode) {
639648
if (options.iosVersion) {
640649
return callback(new Error(__('Unable to find any Xcode installations that supports iOS %s.', options.iosVersion)));
650+
} else if (options.minIosVersion) {
651+
return callback(new Error(__('Unable to find any Xcode installations that supports at least iOS %s.', options.minIosVersion)));
641652
} else {
642653
return callback(new Error(__('Unable to find any supported Xcode installations. Please install the latest Xcode.')));
643654
}

0 commit comments

Comments
 (0)