@@ -310,15 +310,17 @@ const createRun =
310310 }
311311
312312 if ( args . udid ) {
313- const device = devices . find ( ( d ) => d . udid === args . udid ) ;
313+ let device = devices . find ( ( d ) => d . udid === args . udid ) ;
314314 if ( ! device ) {
315- return logger . error (
315+ // We may be able to recover from this for macCatalyst app starts,
316+ // but the general case is this is a problem and device list will help
317+ logger . warn (
316318 `Could not find a device with udid: "${ chalk . bold (
317319 args . udid ,
318320 ) } ". ${ printFoundDevices ( devices ) } `,
319321 ) ;
320322 }
321- if ( device . type === 'simulator' ) {
323+ if ( device ? .type === 'simulator' ) {
322324 return runOnSimulator (
323325 xcodeProject ,
324326 platformName ,
@@ -328,6 +330,20 @@ const createRun =
328330 fallbackSimulator ,
329331 ) ;
330332 } else {
333+ if ( ! device ) {
334+ // On arm64 machines, the catalyst UDID returned by 'xcrun xctrace list devices' is not correct
335+ // xcodebuild will return an error indicating the UDID is unknown and offering a different one
336+ // you may obtain it by running xcodebuild with the UDID you think works then parse out the other one from the returned error:
337+ // CATALYST_DESTINATION=$(xcodebuild -workspace ios/rnfbdemo.xcworkspace -configuration Debug -scheme rnfbdemo -destination id=7153382A-C92B-5798-BEA3-D82D195F25F8 2>&1|grep macOS|grep Catalyst|head -1 |cut -d':' -f5 |cut -d' ' -f1)
338+ //
339+ // How to handle the incorrect catalyst UDID?
340+ // Assume if a UDID is specified, the user knows what they are doing.
341+ // Use the given UDID and force the type, so "catalyst" will launch the app correctly
342+ device = { name : 'unknown' , udid : args . udid , type : 'catalyst' } ;
343+ logger . warn (
344+ 'Running with provided udid anyway, and type "catalyst". \'xcodebuild\' command may return error.' ,
345+ ) ;
346+ }
331347 return runOnDevice (
332348 device ,
333349 platformName ,
0 commit comments