Actually use unit tested function in wrapped xcode check

Summary: Accidentally tested a function that should have been called from the internals. This makes the internal function use the check.

Reviewed By: lblasa

Differential Revision: D34139589

fbshipit-source-id: fac13f7b54ffb0b6f501fb9237f55766706e975a
This commit is contained in:
Lawrence Lomax
2022-02-10 07:56:49 -08:00
committed by Facebook GitHub Bot
parent 3871755064
commit 84fac685ac

View File

@@ -192,29 +192,28 @@ export class IOSDeviceManager {
async checkXcodeVersionMismatch() { async checkXcodeVersionMismatch() {
try { try {
let {stdout: xcodeCLIVersion} = await exec('xcode-select -p'); const {stdout: xcodeSelectStdout} = await exec('xcode-select -p');
xcodeCLIVersion = xcodeCLIVersion!.toString().trim(); const xcodeCLIVersion = xcodeSelectStdout!.toString().trim();
const {stdout} = await exec( const {stdout: simulatorProcessStdout} = await exec(
"pgrep Simulator | xargs ps -o command | grep -v grep | grep Simulator.app | awk '{print $1}'", "pgrep Simulator | xargs ps -o command | grep -v grep | grep Simulator.app | awk '{print $1}'",
); );
for (const runningSimulatorApp of stdout!.toString().split('\n')) { const runningSimulatorApplications = simulatorProcessStdout!
if (!runningSimulatorApp) { .toString()
continue; .split('\n')
.filter((application) => application.length > 0);
const mismatchedVersion = checkXcodeVersionMismatch(
runningSimulatorApplications,
xcodeCLIVersion,
);
if (mismatchedVersion === undefined) {
return;
} }
if (runningSimulatorApp.startsWith(xcodeCLIVersion)) { const errorMessage = `Xcode version mismatch: Simulator is running from "${mismatchedVersion}" while Xcode CLI is "${xcodeCLIVersion}". Running "xcode-select --switch ${xcodeCLIVersion}" can fix this. For example: "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"`;
continue;
}
const runningVersion =
runningSimulatorApp.split('/Contents/Developer')[0] +
'/Contents/Developer';
const errorMessage = `Xcode version mismatch: Simulator is running from "${runningVersion}" while Xcode CLI is "${xcodeCLIVersion}". Running "xcode-select --switch ${runningVersion}" can fix this. For example: "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"`;
this.flipperServer.emit('notification', { this.flipperServer.emit('notification', {
type: 'error', type: 'error',
title: 'Xcode version mismatch', title: 'Xcode version mismatch',
description: '' + errorMessage, description: '' + errorMessage,
}); });
break;
}
} catch (e) { } catch (e) {
console.error('Failed to determine Xcode version:', e); console.error('Failed to determine Xcode version:', e);
} }