* Generic function spawning `xcodebuild` process.
(args: string[], settings?: XcodebuildSettings)
| 137 | * Generic function spawning `xcodebuild` process. |
| 138 | */ |
| 139 | async xcodebuildAsync(args: string[], settings?: XcodebuildSettings) { |
| 140 | // `xcodebuild` writes error details to stdout but we don't want to pollute our output if nothing wrong happens. |
| 141 | // Spawn it quietly, capture stdout + stderr, and print them only on failure. |
| 142 | const finalArgs = ['-quiet', ...args]; |
| 143 | |
| 144 | if (settings) { |
| 145 | finalArgs.unshift( |
| 146 | ...Object.entries(settings).map(([key, value]) => { |
| 147 | return `${key}=${parseXcodeSettingsValue(value)}`; |
| 148 | }) |
| 149 | ); |
| 150 | } |
| 151 | try { |
| 152 | await spawnAsync('xcodebuild', finalArgs, { |
| 153 | cwd: this.rootDir, |
| 154 | stdio: ['ignore', 'pipe', 'pipe'], |
| 155 | }); |
| 156 | } catch (e) { |
| 157 | // Print formatted Xcode logs (merged from stdout and stderr). |
| 158 | process.stdout.write(formatXcodeBuildOutput((e.stdout ?? '') + (e.stderr ?? ''))); |
| 159 | throw e; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Cleans shared derived data directory. |
no test coverage detected