( ctx: XcodeStateReaderContext, simulatorId: string, )
| 195 | } |
| 196 | |
| 197 | export async function lookupSimulatorName( |
| 198 | ctx: XcodeStateReaderContext, |
| 199 | simulatorId: string, |
| 200 | ): Promise<string | undefined> { |
| 201 | const { executor } = ctx; |
| 202 | |
| 203 | const result = await executor( |
| 204 | ['xcrun', 'simctl', 'list', 'devices', 'available', '--json'], |
| 205 | 'List simulators', |
| 206 | false, |
| 207 | ); |
| 208 | |
| 209 | if (!result.success) { |
| 210 | log('warn', `[xcode-state] Failed to list simulators: ${result.error}`); |
| 211 | return undefined; |
| 212 | } |
| 213 | |
| 214 | try { |
| 215 | const data = JSON.parse(result.output) as { |
| 216 | devices: Record<string, Array<{ udid: string; name: string }>>; |
| 217 | }; |
| 218 | |
| 219 | for (const runtime of Object.values(data.devices)) { |
| 220 | for (const device of runtime) { |
| 221 | if (device.udid === simulatorId) { |
| 222 | return device.name; |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | } catch (e) { |
| 227 | log('warn', `[xcode-state] Failed to parse simulator list: ${e}`); |
| 228 | } |
| 229 | |
| 230 | return undefined; |
| 231 | } |
| 232 | |
| 233 | export async function readXcodeIdeState(ctx: XcodeStateReaderContext): Promise<XcodeStateResult> { |
| 234 | try { |
no test coverage detected