@@ -15,6 +15,21 @@ import {simulatorDestinationMap} from './simulatorDestinationMap';
15
15
import { supportedPlatforms } from '../../config/supportedPlatforms' ;
16
16
import { ApplePlatform } from '../../types' ;
17
17
18
+ function prettifyXcodebuildMessages ( output : string ) : Set < string > {
19
+ const errorRegex = / e r r o r \b [ ^ \S \r \n ] * [: \- \s] * ( [ ^ \r \n ] * ) / gim;
20
+ const errors = new Set < string > ( ) ;
21
+
22
+ let match ;
23
+ while ( ( match = errorRegex . exec ( output ) ) !== null ) {
24
+ if ( match [ 1 ] ) {
25
+ // match[1] contains the captured group that excludes any leading colons or spaces
26
+ errors . add ( match [ 1 ] . trim ( ) ) ;
27
+ }
28
+ }
29
+
30
+ return errors ;
31
+ }
32
+
18
33
export function buildProject (
19
34
xcodeProject : IOSProjectInfo ,
20
35
platform : ApplePlatform ,
@@ -84,7 +99,6 @@ export function buildProject(
84
99
getProcessOptions ( args ) ,
85
100
) ;
86
101
let buildOutput = '' ;
87
- let errorOutput = '' ;
88
102
buildProcess . stdout . on ( 'data' , ( data : Buffer ) => {
89
103
const stringData = data . toString ( ) ;
90
104
buildOutput += stringData ;
@@ -100,10 +114,6 @@ export function buildProject(
100
114
}
101
115
}
102
116
} ) ;
103
-
104
- buildProcess . stderr . on ( 'data' , ( data : Buffer ) => {
105
- errorOutput += data ;
106
- } ) ;
107
117
buildProcess . on ( 'close' , ( code : number ) => {
108
118
if ( xcodebuildOutputFormatter ) {
109
119
xcodebuildOutputFormatter . stdin . end ( ) ;
@@ -112,22 +122,23 @@ export function buildProject(
112
122
}
113
123
if ( code !== 0 ) {
114
124
printRunDoctorTip ( ) ;
125
+ if ( ! xcodebuildOutputFormatter ) {
126
+ Array . from ( prettifyXcodebuildMessages ( buildOutput ) ) . forEach ( ( error ) =>
127
+ logger . error ( error ) ,
128
+ ) ;
129
+ }
130
+
115
131
reject (
116
- new CLIError (
117
- `
118
- Failed to build ${ platform } project.
119
-
120
- "xcodebuild" exited with error code '${ code } '. To debug build
121
- logs further, consider building your app with Xcode.app, by opening
122
- '${ xcodeProject . name } '.
123
- ` ,
124
- xcodebuildOutputFormatter
125
- ? undefined
126
- : buildOutput + '\n' + errorOutput ,
127
- ) ,
132
+ new CLIError ( `
133
+ Failed to build ${ platform } project.
134
+
135
+ "xcodebuild" exited with error code '${ code } '. To debug build
136
+ logs further, consider building your app with Xcode.app, by opening
137
+ '${ xcodeProject . name } '.` ) ,
128
138
) ;
129
139
return ;
130
140
}
141
+
131
142
logger . success ( 'Successfully built the app' ) ;
132
143
resolve ( buildOutput ) ;
133
144
} ) ;
0 commit comments