Skip to content

Commit

Permalink
[TIMOB-26121] iOS: Prioritize selected xcode when determining default…
Browse files Browse the repository at this point in the history
… simulator (#10100)

* [TIMOB-26121] Prioritize selected xcode when determining default simulator

* [TIMOB-26121] Fix order

* [TIMOB-26121] Use same selection logic for simulator
  • Loading branch information
garymathews authored and hansemannn committed Jun 25, 2018
1 parent 402df8e commit d361b57
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -1936,12 +1936,16 @@ iOSBuilder.prototype.validate = function validate(logger, config, cli) {
const xcodeInfo = this.iosInfo.xcode;

function sortXcodeIds(a, b) {
return xcodeInfo[a].selected || appc.version.gt(xcodeInfo[a].version, xcodeInfo[b].version) ? -1 : appc.version.lt(xcodeInfo[a].version, xcodeInfo[b].version) ? 1 : 0;
// prioritize selected xcode
if (xcodeInfo[b].selected) {
return 1;
}
return appc.version.gt(xcodeInfo[a].version, xcodeInfo[b].version) ? -1 : appc.version.lt(xcodeInfo[a].version, xcodeInfo[b].version) ? 1 : 0;
}

if (this.iosSdkVersion) {
// find the Xcode for this version
Object.keys(this.iosInfo.xcode).sort(sortXcodeIds).reverse().some(function (ver) {
Object.keys(this.iosInfo.xcode).sort(sortXcodeIds).some(function (ver) {
if (this.iosInfo.xcode[ver].sdks.indexOf(this.iosSdkVersion) !== -1) {
this.xcodeEnv = this.iosInfo.xcode[ver];
return true;
Expand All @@ -1954,9 +1958,8 @@ iOSBuilder.prototype.validate = function validate(logger, config, cli) {
logger.error(__('Unable to find any Xcode installations that support iOS SDK %s.', this.iosSdkVersion) + '\n');
process.exit(1);
}
} else if (cli.argv.target === 'simulator' && !cli.argv['build-only']) {
// we'll let ioslib suggest an iOS version
} else { // device, dist-appstore, dist-adhoc

} else { // device, simulator, dist-appstore, dist-adhoc
Object.keys(xcodeInfo)
.filter(function (id) { return xcodeInfo[id].supported; })
.sort(sortXcodeIds)
Expand Down

0 comments on commit d361b57

Please sign in to comment.