apache / cordova-paramedic

Apache Cordova - Paramedic
https://cordova.apache.org/
Apache License 2.0
36 stars 53 forks source link

cordova-paramedic crashes at "Filtering for Targeted Emulator" with Xcode 13 ("failed to locate 'instruments'") #225

Closed airdrummingfool closed 2 years ago

airdrummingfool commented 2 years ago

Bug Report

Problem

What is expected to happen?

I can run cordova-paramedic to test an iOS app with Xcode 13 installed on my machine.

What does actually happen?

cordova-paramedic calls instruments to list the available simulators, but the instruments command was deprecated in Xcode 12 and removed in Xcode 13. The process crashes on this call.

Information

Deprecation warning when calling instruments on Xcode 12:

Filtering for Targeted Emulator: /^iPhone/
running:
    instruments -s devices | grep ^iPhone
$ instruments -s devices | grep ^iPhone
instruments` is now deprecated in favor of 'xcrun xctrace' (see `man xctrace` for more information on its replacement)

Stack trace of the crash on Xcode 13:

Filtering for Targeted Emulator: /^iPhone/
running:
    instruments -s devices | grep ^iPhone
$ instruments -s devices | grep ^iPhone
instruments: error: Failed to locate 'instruments'.
xcode-select: Failed to locate 'instruments', requesting installation of command line developer tools.
Error: Failed to get the list of simulators
Error: simulators.reduce is not a function
TypeError: simulators.reduce is not a function
    at Object.getSimulatorData (/Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/lib/utils/utilities.js:136:10)
    at ParamedicTargetChooser.chooseTargetForIOS (/Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/lib/ParamedicTargetChooser.js:140:41)
    at ParamedicTargetChooser.chooseTarget (/Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/lib/ParamedicTargetChooser.js:43:30)
    at ParamedicRunner.getCommandForStartingTests (/Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/lib/paramedic.js:425:78)
    at /Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/lib/paramedic.js:239:30
From previous event:
    at ParamedicRunner.runLocalTests (/Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/lib/paramedic.js:279:14)
    at ParamedicRunner.runTests (/Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/lib/paramedic.js:375:25)
    at /Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/lib/paramedic.js:93:29
From previous event:
    at ParamedicRunner.run (/Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/lib/paramedic.js:79:14)
    at Object.exports.run (/Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/lib/paramedic.js:500:19)
    at Object.<anonymous> (/Users/user/Documents/CordovaProject/node_modules/cordova-paramedic/main.js:184:15)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)

Command or Code

npx cordova-paramedic --platform ios --plugin my-plugin --verbose

Environment, Platform, Device

macOS Big Sur, Xcode 13

Version information

macOS: 11.6 Xcode: 13.0 cordova-paramedic: latest (1.0.0-dev) ios-deploy: 1.11.4

Checklist

airdrummingfool commented 2 years ago

Possibly relevant cordova-ios feature request: https://github.com/apache/cordova-ios/issues/595

airdrummingfool commented 2 years ago

Based on https://github.com/facebook/flipper/commit/795a3d30a0638ff0e2ccbd0571415d0f6d92710c, it looks like xcrun xctrace list devices is a good replacement, though the output does not line up exactly.

instruments -s devices output format:

iPhone 12 (14.5) [0AFC41A6-E65C-484A-89C8-EC756B330821] (Simulator)
iPhone 12 (14.5) + Apple Watch Series 5 - 44mm (7.4) [DC773D49-C704-4BA2-A3C1-A6FCAA68B047] (Simulator)
iPhone 12 Pro (14.2) [431BEFD5-C804-47F4-AD53-C246CD5CA844] (Simulator)
[...]

xcrun xctrace list devices output format:

iPhone 12 Pro Simulator (15.0) (14B3DA19-0752-4484-B393-AC95EF2D46F8)
iPhone 12 Pro Simulator (15.0) + Apple Watch Series 5 - 40mm (8.0) (0F1B3157-681A-4562-8331-896A30D569BE)
iPhone 12 Pro Max Simulator (15.0) (35E8AAE8-1FFC-42E4-9039-EAA5FC48E458)