1c4ef02aeSEvan Baconimport { isSimulatorDevice, resolveDeviceAsync } from './resolveDevice'; 2c4ef02aeSEvan Baconimport { resolveNativeSchemePropsAsync } from './resolveNativeScheme'; 3c4ef02aeSEvan Baconimport { resolveXcodeProject } from './resolveXcodeProject'; 4*8a424bebSJames Ideimport { isOSType } from '../../../start/platforms/ios/simctl'; 5*8a424bebSJames Ideimport { resolveBundlerPropsAsync } from '../../resolveBundlerProps'; 6*8a424bebSJames Ideimport { BuildProps, Options } from '../XcodeBuild.types'; 7c4ef02aeSEvan Bacon 8c4ef02aeSEvan Bacon/** Resolve arguments for the `run:ios` command. */ 9c4ef02aeSEvan Baconexport async function resolveOptionsAsync( 10c4ef02aeSEvan Bacon projectRoot: string, 11c4ef02aeSEvan Bacon options: Options 12c4ef02aeSEvan Bacon): Promise<BuildProps> { 13c4ef02aeSEvan Bacon const xcodeProject = resolveXcodeProject(projectRoot); 14c4ef02aeSEvan Bacon 15c4ef02aeSEvan Bacon const bundlerProps = await resolveBundlerPropsAsync(projectRoot, options); 16c4ef02aeSEvan Bacon 17c4ef02aeSEvan Bacon // Resolve the scheme before the device so we can filter devices based on 18c4ef02aeSEvan Bacon // whichever scheme is selected (i.e. don't present TV devices if the scheme cannot be run on a TV). 19c4ef02aeSEvan Bacon const { osType, name: scheme } = await resolveNativeSchemePropsAsync( 20c4ef02aeSEvan Bacon projectRoot, 21c4ef02aeSEvan Bacon options, 22c4ef02aeSEvan Bacon xcodeProject 23c4ef02aeSEvan Bacon ); 24c4ef02aeSEvan Bacon 25c4ef02aeSEvan Bacon // Resolve the device based on the provided device id or prompt 26c4ef02aeSEvan Bacon // from a list of devices (connected or simulated) that are filtered by the scheme. 27c4ef02aeSEvan Bacon const device = await resolveDeviceAsync(options.device, { 28c4ef02aeSEvan Bacon // It's unclear if there's any value to asserting that we haven't hardcoded the os type in the CLI. 29c4ef02aeSEvan Bacon osType: isOSType(osType) ? osType : undefined, 30c4ef02aeSEvan Bacon }); 31c4ef02aeSEvan Bacon 32c4ef02aeSEvan Bacon const isSimulator = isSimulatorDevice(device); 33c4ef02aeSEvan Bacon 34c4ef02aeSEvan Bacon // Use the configuration or `Debug` if none is provided. 35c4ef02aeSEvan Bacon const configuration = options.configuration || 'Debug'; 36c4ef02aeSEvan Bacon 37c4ef02aeSEvan Bacon // This optimization skips resetting the Metro cache needlessly. 38c4ef02aeSEvan Bacon // The cache is reset in `../node_modules/react-native/scripts/react-native-xcode.sh` when the 39c4ef02aeSEvan Bacon // project is running in Debug and built onto a physical device. It seems that this is done because 40c4ef02aeSEvan Bacon // the script is run from Xcode and unaware of the CLI instance. 41c4ef02aeSEvan Bacon const shouldSkipInitialBundling = configuration === 'Debug' && !isSimulator; 42c4ef02aeSEvan Bacon 43c4ef02aeSEvan Bacon return { 44c4ef02aeSEvan Bacon ...bundlerProps, 45c4ef02aeSEvan Bacon projectRoot, 46c4ef02aeSEvan Bacon isSimulator, 47c4ef02aeSEvan Bacon xcodeProject, 48c4ef02aeSEvan Bacon device, 49c4ef02aeSEvan Bacon configuration, 50c4ef02aeSEvan Bacon shouldSkipInitialBundling, 51c4ef02aeSEvan Bacon buildCache: options.buildCache !== false, 52c4ef02aeSEvan Bacon scheme, 53c4ef02aeSEvan Bacon }; 54c4ef02aeSEvan Bacon} 55