Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): Fixed semver ranges #102

Merged
merged 5 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
68 changes: 39 additions & 29 deletions lib/simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,27 +178,38 @@ function detect(options, callback) {
return callback(null, results);
}

const typeRE = /iOS|watchOS/i;
const deviceTypeLookup = {};
const runtimeLookup = {};

xcodeIds.forEach(function (xcodeId) {
var xc = xcodeInfo.xcode[xcodeId];

Object.keys(xc.simDeviceTypes).forEach(function (id) {
deviceTypeLookup[id] = {
name: xc.simDeviceTypes[id].name,
model: xc.simDeviceTypes[id].model,
supportsWatch: xc.simDeviceTypes[id].supportsWatch
};
if (!deviceTypeLookup[id]) {
deviceTypeLookup[id] = {
name: xc.simDeviceTypes[id].name,
model: xc.simDeviceTypes[id].model,
supportsWatch: xc.simDeviceTypes[id].supportsWatch
};
}
});

Object.keys(xc.simRuntimes).forEach(function (id) {
runtimeLookup[id] = {
name: xc.simRuntimes[id].name,
version: xc.simRuntimes[id].version,
simctl: xc.executables.simctl,
simulator: xc.executables[/watch/i.test(xc.simRuntimes[id].name) ? 'watchsimulator' : 'simulator'],
xcodeIds: [ xcodeId ]
};
if (typeRE.test(id)) {
if (!runtimeLookup[id]) {
runtimeLookup[id] = {
name: xc.simRuntimes[id].name,
version: xc.simRuntimes[id].version,
simctl: xc.executables.simctl,
simulator: xc.executables[/watch/i.test(xc.simRuntimes[id].name) ? 'watchsimulator' : 'simulator'],
xcodeIds: []
};
}
if (runtimeLookup[id].xcodeIds.indexOf(xcodeId) === -1) {
runtimeLookup[id].xcodeIds.push(xcodeId);
}
}
});
});

Expand All @@ -218,22 +229,22 @@ function detect(options, callback) {
}
});
info.runtimes.forEach(function (runtime) {
if (!runtimeLookup[runtime.identifier]) {
var xcodeIds = [];
if (typeRE.test(runtime.identifier)) {
if (!runtimeLookup[runtime.identifier]) {
runtimeLookup[runtime.identifier] = {
name: runtime.name,
version: runtime.version,
simctl: xc.executables.simctl,
simulator: xc.executables[/watch/i.test(xc.simRuntimes[runtime.version].name) ? 'watchsimulator' : 'simulator'],
xcodeIds: []
};
}
xcodeIds.forEach(function (xcodeId) {
var xc = xcodeInfo.xcode[xcodeId];
if (xc.simRuntimes[runtime.version]) {
xcodeIds.push(xcodeId);
if (xc.simRuntimes[runtime.version] && runtimeLookup[runtime.identifier].xcodeIds.indexOf(xcodeId) === -1) {
runtimeLookup[runtime.identifier].xcodeIds.push(xcodeId);
}
});

runtimeLookup[runtime.identifier] = {
name: runtime.name,
version: runtime.version,
simctl: xcodeInfo.selectedXcode.executables.simctl,
simulator: xcodeInfo.selectedXcode.executables[/watch/i.test(runtime.name) ? 'watchsimulator' : 'simulator'],
xcodeIds: xcodeIds
};
}
});

Expand Down Expand Up @@ -1739,8 +1750,8 @@ function launch(simHandleOrUDID, options, callback) {
/**
* Determines if the iOS Simulator is running by scanning the output of the `ps` command.
*
* @param {String} proc - The path of the executable to find the pid for
* @param {Function} callback - A function to call with the pid
* @param {String} proc - The path of the executable to find the pid for.
* @param {Function} callback - A function to call with the err, pid, and udid.
*/
function isSimulatorRunning(proc, callback) {
appc.subprocess.run('ps', '-ef', function (code, out, err) {
Expand All @@ -1755,9 +1766,8 @@ function isSimulatorRunning(proc, callback) {
procRE = /^\s*\d+\s+(\d+).* \-CurrentDeviceUDID (.+)/;

for (; i < l; i++) {
if (lines[i].indexOf(proc) !== -1) {
m = lines[i].match(procRE);
return m ? callback(null, parseInt(m[1]), m[2]) : callback();
if (m = lines[i].match(procRE)) {
return callback(null, parseInt(m[1]), m[2]);
}
}

Expand Down
10 changes: 5 additions & 5 deletions lib/xcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ const simulatorDevicePairCompatibility = {
'>=9.0 <=9.2': { // iOS 9.0, 9.1, 9.2
'>=2.0 <=2.1': true // watchOS 2.0, 2.1
},
'>=9.3': { // iOS 9.x
'>=9.3 <10': { // iOS 9.3
'2.2': true // watchOS 2.2
}
},
'8.x': { // Xcode 8.x
'>=9.0 <=9.2': { // iOS 9.0, 9.1, 9.2
'>=2.0 <=2.1': true // watchOS 2.0, 2.1
},
'>=9.3': { // iOS 9.x
'>=9.3 <10': { // iOS 9.x
'2.2': true, // watchOS 2.2
'3.x': true // watchOS 3.x
},
Expand All @@ -72,7 +72,7 @@ const simulatorDevicePairCompatibility = {
'>=9.0 <=9.2': { // iOS 9.0, 9.1, 9.2
'>=2.0 <=2.1': true // watchOS 2.0, 2.1
},
'>=9.3': { // iOS 9.x
'>=9.3 <10': { // iOS 9.x
'2.2': true, // watchOS 2.2
'3.x': true // watchOS 3.x
},
Expand All @@ -90,15 +90,15 @@ const simulatorDevicePairCompatibility = {
'>=9.0 <=9.2': { // iOS 9.0, 9.1, 9.2
'>=2.0 <=2.1': true // watchOS 2.0, 2.1
},
'>=9.3': { // iOS 9.x
'>=9.3 <10': { // iOS 9.x
'2.2': true, // watchOS 2.2
'3.x': true // watchOS 3.x
},
'>=10.0 <=10.2': { // iOS 10.0, 10.1, 10.2
'2.2': true, // watchOS 2.2
'3.x': true // watchOS 3.x
},
'>=10.3': { // iOS 10.3
'>=10.3 <11': { // iOS 10.3
'3.x': true // watchOS 3.x
},
'11.x': { // iOS 11.x
Expand Down