1
- import { installPods } from '@react-native-community/cli-doctor' ;
2
1
import fs from 'fs-extra' ;
3
2
import path from 'path' ;
4
3
import * as fetch from 'npm-registry-fetch' ;
@@ -9,6 +8,7 @@ import semver from 'semver';
9
8
import generateFileHash from './generateFileHash' ;
10
9
import { getLoader } from './loader' ;
11
10
import logger from './logger' ;
11
+ import { CLIError } from './errors' ;
12
12
13
13
export interface DependencyData {
14
14
path : string ;
@@ -21,6 +21,26 @@ function isUsingYarn(root: string) {
21
21
return fs . existsSync ( path . join ( root , 'yarn.lock' ) ) ;
22
22
}
23
23
24
+ async function podInstall ( ) {
25
+ process . chdir ( 'ios' ) ;
26
+ const loader = getLoader ( ) ;
27
+ try {
28
+ loader . start ( 'Installing pods...' ) ;
29
+ await execa ( 'bundle' , [ 'exec' , 'pod' , 'install' ] ) ;
30
+ loader . succeed ( ) ;
31
+ } catch ( error ) {
32
+ const stderr = ( error as any ) . stderr || ( error as any ) . stdout ;
33
+ loader . fail ( ) ;
34
+ logger . error ( stderr ) ;
35
+
36
+ throw new CLIError (
37
+ 'Could not install pods. Try running pod installation manually.' ,
38
+ ) ;
39
+ } finally {
40
+ process . chdir ( '..' ) ;
41
+ }
42
+ }
43
+
24
44
function writeFile ( filePath : string , content : string ) {
25
45
fs . writeFileSync ( filePath , content , { encoding : 'utf8' } ) ;
26
46
}
@@ -380,10 +400,7 @@ async function resolvePodsInstallation() {
380
400
} ) ;
381
401
382
402
if ( install ) {
383
- const loader = getLoader ( { text : 'Installing pods...' } ) ;
384
- loader . start ( ) ;
385
- await installPods ( loader ) ;
386
- loader . succeed ( ) ;
403
+ await podInstall ( ) ;
387
404
}
388
405
}
389
406
0 commit comments