@@ -153,6 +153,9 @@ async function main() {
153153 } ,
154154 { phase : phaseSetup } ,
155155 ) ;
156+ await measuredStep ( "fixture app registration" , waitForFixtureRegistration , {
157+ phase : phaseSetup ,
158+ } ) ;
156159
157160 await measuredStep (
158161 "setup launch SwiftUI fixture" ,
@@ -815,16 +818,16 @@ async function ensureFixtureForeground(label, options = {}) {
815818 ) ;
816819 } catch ( error ) {
817820 launchError = error ;
818- logStep (
819- `${ label } : launch command reported ${ String ( error ?. message ?? error ) . split ( "\n" ) [ 0 ] } ` ,
820- ) ;
821+ logStep ( `${ label } : launch command reported ${ summarizeError ( error ) } ` ) ;
821822 }
822823
823824 try {
824825 return await verifyUi ( label , {
825826 expectFixture : true ,
826- attempts : options . verifyAttempts ?? 8 ,
827+ attempts : options . verifyAttempts ?? ( launchError === null ? 8 : 2 ) ,
827828 delayMs : options . verifyDelayMs ?? 1_000 ,
829+ waitTimeoutMs :
830+ options . waitTimeoutMs ?? ( launchError === null ? 5_000 : 1_000 ) ,
828831 } ) ;
829832 } catch ( verifyError ) {
830833 if ( launchError === null ) {
@@ -859,6 +862,37 @@ async function ensureFixtureForeground(label, options = {}) {
859862 } ) ;
860863}
861864
865+ async function waitForFixtureRegistration ( ) {
866+ let lastError = null ;
867+ for ( let attempt = 1 ; attempt <= 12 ; attempt += 1 ) {
868+ try {
869+ const appContainer = runText (
870+ "xcrun" ,
871+ [ "simctl" , "get_app_container" , simulatorUDID , fixtureBundleId ] ,
872+ { timeoutMs : 60_000 } ,
873+ ) . trim ( ) ;
874+ if ( appContainer . length > 0 ) {
875+ logStep ( `fixture registered at ${ appContainer } ` ) ;
876+ return appContainer ;
877+ }
878+ } catch ( error ) {
879+ lastError = error ;
880+ }
881+ await sleep ( 1_000 ) ;
882+ }
883+ throw new Error (
884+ `fixture app was not registered after install: ${ summarizeError ( lastError ) } ` ,
885+ ) ;
886+ }
887+
888+ function summarizeError ( error ) {
889+ return String ( error ?. message ?? error )
890+ . split ( "\n" )
891+ . filter ( Boolean )
892+ . slice ( 0 , 3 )
893+ . join ( " | " ) ;
894+ }
895+
862896function cliArgs ( args ) {
863897 return args ;
864898}
0 commit comments