( params: ResolveAppPathFromBuildSettingsParams, executor: CommandExecutor, )
| 41 | * destination is derived from `platform` and optional `deviceId`. |
| 42 | */ |
| 43 | export async function resolveAppPathFromBuildSettings( |
| 44 | params: ResolveAppPathFromBuildSettingsParams, |
| 45 | executor: CommandExecutor, |
| 46 | ): Promise<string> { |
| 47 | const command = ['xcodebuild', '-showBuildSettings']; |
| 48 | |
| 49 | const workspacePath = resolvePathFromCwd(params.workspacePath); |
| 50 | const projectPath = resolvePathFromCwd(params.projectPath); |
| 51 | const derivedDataPath = resolveEffectiveDerivedDataPath({ |
| 52 | derivedDataPath: params.derivedDataPath, |
| 53 | workspacePath, |
| 54 | projectPath, |
| 55 | }); |
| 56 | |
| 57 | let projectDir: string | undefined; |
| 58 | |
| 59 | if (projectPath) { |
| 60 | command.push('-project', projectPath); |
| 61 | projectDir = path.dirname(projectPath); |
| 62 | } else if (workspacePath) { |
| 63 | command.push('-workspace', workspacePath); |
| 64 | projectDir = path.dirname(workspacePath); |
| 65 | } |
| 66 | |
| 67 | command.push('-scheme', params.scheme); |
| 68 | command.push('-configuration', params.configuration ?? 'Debug'); |
| 69 | |
| 70 | const destination = |
| 71 | params.destination ?? getBuildSettingsDestination(params.platform, params.deviceId); |
| 72 | command.push('-destination', destination); |
| 73 | |
| 74 | command.push('-derivedDataPath', derivedDataPath); |
| 75 | |
| 76 | if (params.extraArgs && params.extraArgs.length > 0) { |
| 77 | command.push(...params.extraArgs); |
| 78 | } |
| 79 | |
| 80 | const result = await executor( |
| 81 | command, |
| 82 | 'Get App Path', |
| 83 | false, |
| 84 | projectDir ? { cwd: projectDir } : undefined, |
| 85 | ); |
| 86 | |
| 87 | if (!result.success) { |
| 88 | throw new Error(result.error ?? 'Unknown error'); |
| 89 | } |
| 90 | |
| 91 | return extractAppPathFromBuildSettingsOutput(result.output); |
| 92 | } |
no test coverage detected