File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -424,6 +424,29 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
424424 tempDirectory ,
425425 ) ;
426426 const xcodeProjectDir = path . join ( tempDirectory , "cocoapods" ) ;
427+
428+ // If ADSF version manager is installed, get the config for the project directory and write it to the temporary project directory
429+ const asdfResult = await this . childProcess . spawnFromEvent (
430+ "asdf" ,
431+ [ "list" , "ruby" ] ,
432+ "exit" ,
433+ ) ;
434+ const asdfVersionMatch = ( asdfResult . stdout as string ) . match (
435+ SysInfo . VERSION_REGEXP ,
436+ ) ;
437+
438+ if ( asdfVersionMatch ?. [ 0 ] ) {
439+ const asdfVersion = asdfVersionMatch [ 0 ] ;
440+ const asdfConfigPath = path . join ( xcodeProjectDir , ".tool-versions" ) ;
441+ const wroteASDFConfig = this . fileSystem . appendFile (
442+ asdfConfigPath ,
443+ `ruby ${ asdfVersion } ` ,
444+ ) ;
445+ if ( ! wroteASDFConfig ) {
446+ console . warn ( `Cocoapods invocation may fail, check asdf config` ) ;
447+ }
448+ }
449+
427450 const spawnResult = await this . childProcess . spawnFromEvent (
428451 "pod" ,
429452 [ "install" ] ,
@@ -432,6 +455,7 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
432455 ) ;
433456 return ! spawnResult . exitCode ;
434457 } catch ( err ) {
458+ console . log ( `Pod command failed - ${ err } ` ) ;
435459 return false ;
436460 } finally {
437461 this . fileSystem . deleteEntry ( tempDirectory ) ;
Original file line number Diff line number Diff line change @@ -8,6 +8,17 @@ export class FileSystem {
88 return fs . existsSync ( path . resolve ( filePath ) ) ;
99 }
1010
11+ public appendFile ( filePath : string , text : string ) : boolean {
12+ let success = false ;
13+ try {
14+ fs . appendFileSync ( path . resolve ( filePath ) , text ) ;
15+ success = true ;
16+ } catch ( err ) {
17+ console . error ( `appendFile failed with ${ err } ` ) ;
18+ }
19+ return success ;
20+ }
21+
1122 public extractZip ( pathToZip : string , outputDir : string ) : Promise < void > {
1223 return new Promise ( ( resolve , reject ) => {
1324 yauzl . open (
@@ -46,7 +57,7 @@ export class FileSystem {
4657 zipFile . once ( "end" , ( ) => resolve ( ) ) ;
4758
4859 zipFile . readEntry ( ) ;
49- }
60+ } ,
5061 ) ;
5162 } ) ;
5263 }
@@ -57,7 +68,7 @@ export class FileSystem {
5768
5869 public readJson < T > (
5970 filePath : string ,
60- options ?: { encoding ?: null ; flag ?: string }
71+ options ?: { encoding ?: null ; flag ?: string } ,
6172 ) : T {
6273 const content = fs . readFileSync ( filePath , options ) ;
6374 return JSON . parse ( content . toString ( ) ) ;
You can’t perform that action at this time.
0 commit comments