Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
check if ios simulators are available
Browse files Browse the repository at this point in the history
Reviewed By: lblasa

Differential Revision: D56937648

fbshipit-source-id: c7b6c38dd7e9a5546dc0271dcd0e8f1ee96921e6
  • Loading branch information
antonk52 authored and facebook-github-bot committed May 3, 2024
1 parent 1c7cd07 commit 92a7a57
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
43 changes: 43 additions & 0 deletions desktop/doctor/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,49 @@ export function getHealthchecks(): FlipperDoctor.Healthchecks {
};
},
},
{
key: 'ios.has-simulators',
label: 'Simulators are available',
isRequired: true,
run: async (
_e: FlipperDoctor.EnvironmentInfo,
settings?: {enablePhysicalIOS: boolean; idbPath: string},
): Promise<FlipperDoctor.HealthcheckRunResult> => {
const result = await tryExecuteCommand(
`${settings?.idbPath ?? 'idb'} list-targets --json`,
);
if (result.fail) {
return {
hasProblem: true,
message: [
'ios.has-simulators--idb-failed',
{message: result.message},
],
};
}

const devices = result.stdout
.trim()
.split('\n')
.map((x) => JSON.parse(x))
.filter((x) => x.type === 'simulator');

if (devices.length === 0) {
return {
hasProblem: true,
message: ['ios.has-simulators--no-devices'],
};
}

return {
hasProblem: false,
message: [
'ios.has-simulators--ok',
{count: devices.length},
],
};
},
},
{
key: 'ios.xctrace',
label: 'xctrace exists',
Expand Down
4 changes: 4 additions & 0 deletions desktop/flipper-common/src/doctor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ export namespace FlipperDoctor {
'ios.sdk--installed': [{platforms: string[]}];
'ios.sdk--not_installed': [];

'ios.has-simulators--idb-failed': [{message: string}];
'ios.has-simulators--no-devices': [];
'ios.has-simulators--ok': [{count: number}];

'ios.xctrace--installed': [{output: string}];
'ios.xctrace--not_installed': [{message: string}];

Expand Down
26 changes: 26 additions & 0 deletions desktop/flipper-ui/src/sandy-chrome/doctor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,28 @@ const IosSdkInstalled = (props: PropsFor<'ios.sdk--installed'>) => (
</div>
);

const HasSimulatorsOk = (props: PropsFor<'ios.has-simulators--ok'>) => (
<Typography.Paragraph>
You have {props.count} simulators available.
</Typography.Paragraph>
);
const HasSimulatorsIdbFailed = (
props: PropsFor<'ios.has-simulators--idb-failed'>,
) => (
<Typography.Paragraph>
Command to list devices failed, make sure idb is installed.
<CodeBlock>{props.message}</CodeBlock>
</Typography.Paragraph>
);
const HasSimulatorsNoDevices = (
_props: PropsFor<'ios.has-simulators--no-devices'>,
) => (
<Typography.Paragraph>
No available simulators found. Launch XCode and install SDK for iOS or run{' '}
<CodeBlock>xcode-select --install</CodeBlock>
</Typography.Paragraph>
);

const IosXctraceInstalled = (props: PropsFor<'ios.xctrace--installed'>) => (
<Typography.Paragraph>
xctrace is installed.
Expand Down Expand Up @@ -319,6 +341,10 @@ const messageToComp: {
'ios.sdk--installed': IosSdkInstalled,
'ios.sdk--not_installed': IosSdkNotInstalled,

'ios.has-simulators--ok': HasSimulatorsOk,
'ios.has-simulators--no-devices': HasSimulatorsNoDevices,
'ios.has-simulators--idb-failed': HasSimulatorsIdbFailed,

'ios.xctrace--installed': IosXctraceInstalled,
'ios.xctrace--not_installed': IosXctraceNotInstalled,

Expand Down

0 comments on commit 92a7a57

Please # to comment.