Tell user when xcode simulator mismatches with xcode-select
Summary: When you run a simulator with a different version of the xcode version that is currently `xcode-select`ed, it won't work. This causes problems in Flipper, and also RN and other tools. Show a helpful warning in this case. Need to dispatch it explicitly because console.errors only get surfaced in dev mode, not production. Ideally this will be done in the doctor, but there's work to get it to report device/app specific problems first. Reviewed By: passy Differential Revision: D19345199 fbshipit-source-id: 45f95c6d33c81da2299d8d84c9179bebb5bfebe8
This commit is contained in:
committed by
Facebook Github Bot
parent
afee624ad6
commit
451db57fa5
@@ -70,7 +70,7 @@ async function queryDevices(store: Store, logger: Logger): Promise<void> {
|
||||
if (!(await checkIfDevicesCanBeQueryied(store))) {
|
||||
return;
|
||||
}
|
||||
await checkXcodeVersionMismatch();
|
||||
await checkXcodeVersionMismatch(store);
|
||||
const {connections} = store.getState();
|
||||
const currentDeviceIDs: Set<string> = new Set(
|
||||
connections.devices
|
||||
@@ -169,7 +169,7 @@ function queryDevicesForever(store: Store, logger: Logger) {
|
||||
}
|
||||
|
||||
let xcodeVersionMismatchFound = false;
|
||||
async function checkXcodeVersionMismatch() {
|
||||
async function checkXcodeVersionMismatch(store: Store) {
|
||||
if (xcodeVersionMismatchFound) {
|
||||
return;
|
||||
}
|
||||
@@ -184,9 +184,17 @@ async function checkXcodeVersionMismatch() {
|
||||
);
|
||||
const runningVersion = match && match.length > 0 ? match[0].trim() : null;
|
||||
if (runningVersion && runningVersion !== xcodeCLIVersion) {
|
||||
console.error(
|
||||
`Xcode version mismatch: Simulator is running from "${runningVersion}" while Xcode CLI is "${xcodeCLIVersion}". Running "xcode-select --switch ${runningVersion}" can fix this.`,
|
||||
);
|
||||
const errorMessage = `Xcode version mismatch: Simulator is running from "${runningVersion}" while Xcode CLI is "${xcodeCLIVersion}". Running "xcode-select --switch ${runningVersion}" can fix this.`;
|
||||
store.dispatch({
|
||||
type: 'SERVER_ERROR',
|
||||
payload: {
|
||||
message: errorMessage,
|
||||
details:
|
||||
"You might want to run 'sudo xcode-select -s /Applications/Xcode.app/Contents/Developer'",
|
||||
},
|
||||
});
|
||||
// Fire a console.error as well, so that it gets reported to the backend.
|
||||
console.error(errorMessage);
|
||||
xcodeVersionMismatchFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user