@@ -20,6 +20,7 @@ import { selectFromInteractiveMode } from '../../utils/selectFromInteractiveMode
2020import { outro , spinner } from '@clack/prompts' ;
2121import { runOnMac } from './runOnMac.js' ;
2222import { runOnMacCatalyst } from './runOnMacCatalyst.js' ;
23+ import { cacheRecentDevice } from './recentDevices.js' ;
2324
2425export const createRun = async (
2526 platformName : ApplePlatform ,
@@ -40,7 +41,12 @@ export const createRun = async (
4041 normalizeArgs ( args , projectRoot , xcodeProject ) ;
4142
4243 const { scheme, mode } = args . interactive
43- ? await selectFromInteractiveMode ( xcodeProject , args . scheme , args . mode )
44+ ? await selectFromInteractiveMode (
45+ xcodeProject ,
46+ sourceDir ,
47+ args . scheme ,
48+ args . mode
49+ )
4450 : await getConfiguration (
4551 xcodeProject ,
4652 sourceDir ,
@@ -75,9 +81,10 @@ export const createRun = async (
7581 ) ;
7682 }
7783 loader . stop ( 'Found available devices and simulators.' ) ;
78- const device = await selectDevice ( devices , args , platformName ) ;
84+ const device = await selectDevice ( devices , args , platformName , projectRoot ) ;
7985
8086 if ( device ) {
87+ cacheRecentDevice ( device , projectRoot , platformName ) ;
8188 if ( device . type === 'simulator' ) {
8289 await runOnSimulator (
8390 device ,
@@ -108,8 +115,13 @@ export const createRun = async (
108115 if ( bootedSimulators . length === 0 ) {
109116 // fallback to present all devices when no device is selected
110117 if ( isInteractive ( ) ) {
111- const simulator = await promptForDeviceSelection ( devices ) ;
118+ const simulator = await promptForDeviceSelection (
119+ devices ,
120+ projectRoot ,
121+ platformName
122+ ) ;
112123 bootedSimulators . push ( simulator ) ;
124+ cacheRecentDevice ( simulator , projectRoot , platformName ) ;
113125 } else {
114126 logger . debug (
115127 'No booted devices or simulators found. Launching first available simulator...'
@@ -146,12 +158,13 @@ export const createRun = async (
146158async function selectDevice (
147159 devices : Device [ ] ,
148160 args : RunFlags ,
149- platform : ApplePlatform
161+ platform : ApplePlatform ,
162+ projectRoot : string
150163) {
151164 const { simulator, udid, interactive } = args ;
152165 let device ;
153166 if ( interactive ) {
154- device = await promptForDeviceSelection ( devices ) ;
167+ device = await promptForDeviceSelection ( devices , projectRoot , platform ) ;
155168 } else if ( udid ) {
156169 device = devices . find ( ( d ) => d . udid === udid ) ;
157170 } else if ( args . device ) {
0 commit comments