@@ -19,6 +19,11 @@ const LIST_TIMEOUT_SECONDS = 40;
1919// expo-device-hub 0.19.1 reports a failed simulator listing only as text; its error ids are hashes.
2020const SIMULATOR_LIST_FAILED =
2121 / ^ \[ a p p l e - u t i l s \] (?: F a i l e d t o (?: r u n ` x c r u n s i m c t l l i s t d e v i c e s | p a r s e J S O N o u t p u t : | l i s t d e v i c e s : ) | ` x c r u n s i m c t l l i s t d e v i c e s - - j s o n ` d i d n o t r e s p o n d w i t h i n ) / ;
22+ // The hub passes numeric display IDs that Xcode 26 rejects; iOS 27 needs them for multiple displays.
23+ const runsOnXcode26Runtime = ( version : string ) => Number ( / ^ i O S ( \d + ) / . exec ( version ) ?. [ 1 ] ) <= 26 ;
24+ const DEFAULT_DISPLAY_SCREENSHOT = `f=$(mktemp -t t3-screenshot) || exit 1
25+ trap 'rm -f "$f"' 0
26+ xcrun simctl io "$1" screenshot --type=png "$f" >/dev/null && base64 -i "$f"` ;
2227
2328const HubDevice = Schema . Struct ( {
2429 id : Schema . String ,
@@ -265,6 +270,24 @@ export const makeDeviceHubOperations = (options: {
265270 } ,
266271 ) ;
267272
273+ const defaultDisplayScreenshot = Effect . fn ( "DeviceHubOperations.defaultDisplayScreenshot" ) (
274+ function * ( udid : string ) {
275+ const capture = yield * run ( "sh" , [ "-c" , DEFAULT_DISPLAY_SCREENSHOT , "sh" , udid ] , {
276+ timeoutMs : Duration . toMillis ( SCREENSHOT_TIMEOUT ) ,
277+ maxOutputBytes : 64 * 1024 * 1024 ,
278+ } ) ;
279+ if ( capture . code !== 0 ) {
280+ return yield * new DeviceOperationError ( {
281+ operation : "screenshot" ,
282+ reason : "command_failed" ,
283+ exitCode : capture . code ,
284+ cause : capture . stderr . trim ( ) ,
285+ } ) ;
286+ }
287+ return new Uint8Array ( Buffer . from ( capture . stdout , "base64" ) ) ;
288+ } ,
289+ ) ;
290+
268291 const screenshot : DeviceOperations [ "screenshot" ] = ( device ) =>
269292 httpClient
270293 . execute (
@@ -289,6 +312,13 @@ export const makeDeviceHubOperations = (options: {
289312 cause,
290313 } ) ,
291314 ) ,
315+ Effect . catchIf (
316+ ( error ) =>
317+ device . platform === "ios" &&
318+ runsOnXcode26Runtime ( device . version ) &&
319+ error . reason === "hub_rejected" ,
320+ ( ) => defaultDisplayScreenshot ( device . id ) ,
321+ ) ,
292322 Effect . withSpan ( "DeviceHubOperations.screenshot" ) ,
293323 ) ;
294324
0 commit comments