(
config: Config,
{
target: selectedTarget,
targetName: selectedTargetName,
targetNameSdkVersion: selectedTargetSdkVersion,
scheme: selectedScheme,
configuration: selectedConfiguration,
}: RunCommandOptions,
)
| 11 | const debug = Debug('capacitor:ios:run'); |
| 12 | |
| 13 | export async function runIOS( |
| 14 | config: Config, |
| 15 | { |
| 16 | target: selectedTarget, |
| 17 | targetName: selectedTargetName, |
| 18 | targetNameSdkVersion: selectedTargetSdkVersion, |
| 19 | scheme: selectedScheme, |
| 20 | configuration: selectedConfiguration, |
| 21 | }: RunCommandOptions, |
| 22 | ): Promise<void> { |
| 23 | const target = await promptForPlatformTarget( |
| 24 | await getPlatformTargets('ios'), |
| 25 | selectedTarget ?? selectedTargetName, |
| 26 | selectedTargetSdkVersion, |
| 27 | selectedTargetName !== undefined, |
| 28 | ); |
| 29 | |
| 30 | const runScheme = selectedScheme || config.ios.scheme; |
| 31 | const configuration = selectedConfiguration || 'Debug'; |
| 32 | |
| 33 | const derivedDataPath = resolve(config.ios.platformDirAbs, 'DerivedData', target.id); |
| 34 | |
| 35 | const packageManager = await config.ios.packageManager; |
| 36 | |
| 37 | let typeOfBuild: string; |
| 38 | let projectName: string; |
| 39 | |
| 40 | if (packageManager !== 'SPM') { |
| 41 | typeOfBuild = '-workspace'; |
| 42 | projectName = basename(await config.ios.nativeXcodeWorkspaceDirAbs); |
| 43 | } else { |
| 44 | typeOfBuild = '-project'; |
| 45 | projectName = basename(await config.ios.nativeXcodeProjDirAbs); |
| 46 | } |
| 47 | |
| 48 | const xcodebuildArgs = [ |
| 49 | typeOfBuild, |
| 50 | projectName, |
| 51 | '-scheme', |
| 52 | runScheme, |
| 53 | '-configuration', |
| 54 | configuration, |
| 55 | '-destination', |
| 56 | `id=${target.id}`, |
| 57 | '-derivedDataPath', |
| 58 | derivedDataPath, |
| 59 | ]; |
| 60 | |
| 61 | debug('Invoking xcodebuild with args: %O', xcodebuildArgs); |
| 62 | |
| 63 | await runTask('Running xcodebuild', async () => |
| 64 | runCommand('xcrun', ['xcodebuild', ...xcodebuildArgs], { |
| 65 | cwd: config.ios.nativeProjectDirAbs, |
| 66 | }), |
| 67 | ); |
| 68 | |
| 69 | const appName = `${runScheme}.app`; |
| 70 | const appPath = resolve( |
no test coverage detected